repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.select_entry | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | python | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | [
"def",
"select_entry",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"smart_search",
"(",
"*",
"arguments",
")",
"if",
"len",
"(",
"matches",
")",
">",
"1",
":",
"logger",
".",
"info",
"(",
"\"More than one match, prompting for... | Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`). | [
"Select",
"a",
"password",
"from",
"the",
"available",
"choices",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L132-L147 |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.simple_search | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | python | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | [
"def",
"simple_search",
"(",
"self",
",",
"*",
"keywords",
")",
":",
"matches",
"=",
"[",
"]",
"keywords",
"=",
"[",
"kw",
".",
"lower",
"(",
")",
"for",
"kw",
"in",
"keywords",
"]",
"logger",
".",
"verbose",
"(",
"\"Performing simple search on %s (%s) ..\... | Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords are
returned. | [
"Perform",
"a",
"simple",
"search",
"for",
"case",
"insensitive",
"substring",
"matches",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L149-L175 |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.smart_search | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | python | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | [
"def",
"smart_search",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"simple_search",
"(",
"*",
"arguments",
")",
"if",
"not",
"matches",
":",
"logger",
".",
"verbose",
"(",
"\"Falling back from substring search to fuzzy search ..\"",
... | Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
- :exc:`.NoMatchingPasswordError` when no matching pas... | [
"Perform",
"a",
"smart",
"search",
"on",
"the",
"given",
"keywords",
"or",
"patterns",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L177-L204 |
xolox/python-qpass | qpass/__init__.py | QuickPass.entries | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | python | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | [
"def",
"entries",
"(",
"self",
")",
":",
"passwords",
"=",
"[",
"]",
"for",
"store",
"in",
"self",
".",
"stores",
":",
"passwords",
".",
"extend",
"(",
"store",
".",
"entries",
")",
"return",
"natsort",
"(",
"passwords",
",",
"key",
"=",
"lambda",
"e... | A list of :class:`PasswordEntry` objects. | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L219-L224 |
xolox/python-qpass | qpass/__init__.py | PasswordStore.context | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | python | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | [
"def",
"context",
"(",
"self",
")",
":",
"# Make sure the directory exists.",
"self",
".",
"ensure_directory_exists",
"(",
")",
"# Prepare the environment variables.",
"environment",
"=",
"{",
"DIRECTORY_VARIABLE",
":",
"self",
".",
"directory",
"}",
"try",
":",
"# Tr... | An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to the
value of :attr:`directory... | [
"An",
"execution",
"context",
"created",
"using",
":",
"mod",
":",
"executor",
".",
"contexts",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L244-L272 |
xolox/python-qpass | qpass/__init__.py | PasswordStore.directory | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | python | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | [
"def",
"directory",
"(",
"self",
",",
"value",
")",
":",
"# Normalize the value of `directory'.",
"set_property",
"(",
"self",
",",
"\"directory\"",
",",
"parse_path",
"(",
"value",
")",
")",
"# Clear the computed values of `context' and `entries'.",
"clear_property",
"("... | Normalize the value of :attr:`directory` when it's set. | [
"Normalize",
"the",
"value",
"of",
":",
"attr",
":",
"directory",
"when",
"it",
"s",
"set",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L292-L298 |
xolox/python-qpass | qpass/__init__.py | PasswordStore.entries | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | python | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | [
"def",
"entries",
"(",
"self",
")",
":",
"timer",
"=",
"Timer",
"(",
")",
"passwords",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"\"Scanning %s ..\"",
",",
"format_path",
"(",
"self",
".",
"directory",
")",
")",
"listing",
"=",
"self",
".",
"context",... | A list of :class:`PasswordEntry` objects. | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L301-L314 |
xolox/python-qpass | qpass/__init__.py | PasswordStore.ensure_directory_exists | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | python | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | [
"def",
"ensure_directory_exists",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"directory",
")",
":",
"msg",
"=",
"\"The password storage directory doesn't exist! (%s)\"",
"raise",
"MissingPasswordStoreError",
"(",
"msg",
... | Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist. | [
"Make",
"sure",
":",
"attr",
":",
"directory",
"exists",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L316-L325 |
xolox/python-qpass | qpass/__init__.py | PasswordEntry.format_text | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | python | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | [
"def",
"format_text",
"(",
"self",
",",
"include_password",
"=",
"True",
",",
"use_colors",
"=",
"None",
",",
"padding",
"=",
"True",
",",
"filters",
"=",
"(",
")",
")",
":",
"# Determine whether we can use ANSI escape sequences.",
"if",
"use_colors",
"is",
"Non... | Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
password from the formatted text.
:param use_colors: :data:`True` to use ANS... | [
"Format",
":",
"attr",
":",
"text",
"for",
"viewing",
"on",
"a",
"terminal",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L362-L428 |
darothen/xbpch | xbpch/util/diaginfo.py | get_diaginfo | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | python | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | [
"def",
"get_diaginfo",
"(",
"diaginfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"diag_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"diag_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".",
"ty... | Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information. | [
"Read",
"an",
"output",
"s",
"diaginfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L39-L66 |
darothen/xbpch | xbpch/util/diaginfo.py | get_tracerinfo | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | python | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | [
"def",
"get_tracerinfo",
"(",
"tracerinfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"tracer_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"tracer_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".... | Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer information. | [
"Read",
"an",
"output",
"s",
"tracerinfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L69-L125 |
darothen/xbpch | xbpch/bpch.py | read_from_bpch | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | python | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | [
"def",
"read_from_bpch",
"(",
"filename",
",",
"file_position",
",",
"shape",
",",
"dtype",
",",
"endian",
",",
"use_mmap",
"=",
"False",
")",
":",
"offset",
"=",
"file_position",
"+",
"4",
"if",
"use_mmap",
":",
"d",
"=",
"np",
".",
"memmap",
"(",
"fi... | Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired data chunk begins
shape : tuple of ints
Resultant (n-dimensional) shape of requested data; the chun... | [
"Read",
"a",
"chunk",
"of",
"data",
"from",
"a",
"bpch",
"output",
"file",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L353-L398 |
darothen/xbpch | xbpch/bpch.py | BPCHDataBundle._read | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | python | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | [
"def",
"_read",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dask",
":",
"d",
"=",
"da",
".",
"from_delayed",
"(",
"delayed",
"(",
"read_from_bpch",
",",
")",
"(",
"self",
".",
"filename",
",",
"self",
".",
"file_position",
",",
"self",
".",
"shape",
... | Helper function to load the data referenced by this bundle. | [
"Helper",
"function",
"to",
"load",
"the",
"data",
"referenced",
"by",
"this",
"bundle",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L68-L84 |
darothen/xbpch | xbpch/bpch.py | BPCHFile.close | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | python | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"fp",
".",
"closed",
":",
"for",
"v",
"in",
"list",
"(",
"self",
".",
"var_data",
")",
":",
"del",
"self",
".",
"var_data",
"[",
"v",
"]",
"self",
".",
"fp",
".",
"close",
"(",
... | Close this bpch file. | [
"Close",
"this",
"bpch",
"file",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L176-L185 |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_metadata | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | python | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | [
"def",
"_read_metadata",
"(",
"self",
")",
":",
"filetype",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"filetitle",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"# Decode to UTF string, if p... | Read the main metadata packaged within a bpch file, indicating
the output filetype and its title. | [
"Read",
"the",
"main",
"metadata",
"packaged",
"within",
"a",
"bpch",
"file",
"indicating",
"the",
"output",
"filetype",
"and",
"its",
"title",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L203-L220 |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_header | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | python | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | [
"def",
"_read_header",
"(",
"self",
")",
":",
"self",
".",
"_header_pos",
"=",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"line",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
"'20sffii'",
")",
"modelname",
",",
"res0",
",",
"res1",
",",
"halfpolar",
... | Process the header information (data model / grid spec) | [
"Process",
"the",
"header",
"information",
"(",
"data",
"model",
"/",
"grid",
"spec",
")"
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L222-L241 |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_var_data | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | python | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | [
"def",
"_read_var_data",
"(",
"self",
")",
":",
"var_bundles",
"=",
"OrderedDict",
"(",
")",
"var_attrs",
"=",
"OrderedDict",
"(",
")",
"n_vars",
"=",
"0",
"while",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"<",
"self",
".",
"fsize",
":",
"var_attr",
... | Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein. | [
"Iterate",
"over",
"the",
"block",
"of",
"this",
"bpch",
"file",
"and",
"return",
"handlers",
"in",
"the",
"form",
"of",
"BPCHDataBundle",
"s",
"for",
"access",
"to",
"the",
"data",
"contained",
"therein",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L244-L350 |
darothen/xbpch | xbpch/common.py | broadcast_1d_array | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | python | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | [
"def",
"broadcast_1d_array",
"(",
"arr",
",",
"ndim",
",",
"axis",
"=",
"1",
")",
":",
"ext_arr",
"=",
"arr",
"for",
"i",
"in",
"range",
"(",
"ndim",
"-",
"1",
")",
":",
"ext_arr",
"=",
"np",
".",
"expand_dims",
"(",
"ext_arr",
",",
"axis",
"=",
... | Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid. | [
"Broadcast",
"1",
"-",
"d",
"array",
"arr",
"to",
"ndim",
"dimensions",
"on",
"the",
"first",
"axis",
"(",
"axis",
"=",
"0",
")",
"or",
"on",
"the",
"last",
"axis",
"(",
"axis",
"=",
"1",
")",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L9-L20 |
darothen/xbpch | xbpch/common.py | get_timestamp | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | python | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | [
"def",
"get_timestamp",
"(",
"time",
"=",
"True",
",",
"date",
"=",
"True",
",",
"fmt",
"=",
"None",
")",
":",
"time_format",
"=",
"\"%H:%M:%S\"",
"date_format",
"=",
"\"%m-%d-%Y\"",
"if",
"fmt",
"is",
"None",
":",
"if",
"time",
"and",
"date",
":",
"fm... | Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the time/date choice and use as
the format string passe... | [
"Return",
"the",
"current",
"timestamp",
"in",
"machine",
"local",
"time",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L23-L49 |
darothen/xbpch | xbpch/common.py | fix_attr_encoding | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | python | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | [
"def",
"fix_attr_encoding",
"(",
"ds",
")",
":",
"def",
"_maybe_del_attr",
"(",
"da",
",",
"attr",
")",
":",
"\"\"\" Possibly delete an attribute on a DataArray if it's present \"\"\"",
"if",
"attr",
"in",
"da",
".",
"attrs",
":",
"del",
"da",
".",
"attrs",
"[",
... | This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer instead of a
boolean, and removes ... | [
"This",
"is",
"a",
"temporary",
"hot",
"-",
"fix",
"to",
"handle",
"the",
"way",
"metadata",
"is",
"encoded",
"when",
"we",
"read",
"data",
"directly",
"from",
"bpch",
"files",
".",
"It",
"removes",
"the",
"scale_factor",
"and",
"units",
"attributes",
"we"... | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L52-L92 |
asmeurer/iterm2-tools | iterm2_tools/shell_integration.py | after_output | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | python | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | [
"def",
"after_output",
"(",
"command_status",
")",
":",
"if",
"command_status",
"not",
"in",
"range",
"(",
"256",
")",
":",
"raise",
"ValueError",
"(",
"\"command_status must be an integer in the range 0-255\"",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"AFTER... | Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255. | [
"Shell",
"sequence",
"to",
"be",
"run",
"after",
"the",
"command",
"output",
"."
] | train | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/shell_integration.py#L153-L164 |
bitlabstudio/django-multilingual-news | multilingual_news/south_migrations/0009_migrate_i18n_fields.py | Migration.forwards | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | python | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"entry_title",
"in",
"orm",
".",
"NewsEntryTitle",
".",
"objects",
".",
"all",
"(",
")",
":",
"entry",
"=",
"NewsEnt... | Write your forwards methods here. | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | train | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0009_migrate_i18n_fields.py#L11-L20 |
darothen/xbpch | xbpch/util/cf.py | get_cfcompliant_units | def get_cfcompliant_units(units, prefix='', suffix=''):
"""
Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of th... | python | def get_cfcompliant_units(units, prefix='', suffix=''):
"""
Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of th... | [
"def",
"get_cfcompliant_units",
"(",
"units",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
")",
":",
"compliant_units",
"=",
"units",
"for",
"gcunits",
",",
"udunits",
"in",
"UNITS_MAP_CTM2CF",
":",
"compliant_units",
"=",
"str",
".",
"replace",
"(",
... | Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of the returned string
(must be a valid udunits2 expression).
... | [
"Get",
"equivalent",
"units",
"that",
"are",
"compatible",
"with",
"the",
"udunits2",
"library",
"(",
"thus",
"CF",
"-",
"compliant",
")",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L67-L112 |
darothen/xbpch | xbpch/util/cf.py | get_valid_varname | def get_valid_varname(varname):
"""
Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on th... | python | def get_valid_varname(varname):
"""
Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on th... | [
"def",
"get_valid_varname",
"(",
"varname",
")",
":",
"vname",
"=",
"varname",
"for",
"s",
",",
"r",
"in",
"VARNAME_MAP_CHAR",
":",
"vname",
"=",
"vname",
".",
"replace",
"(",
"s",
",",
"r",
")",
"return",
"vname"
] | Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on the table stored in
:attr:`VARNAME_MAP_CHA... | [
"Replace",
"characters",
"(",
"e",
".",
"g",
".",
":",
"$",
"=",
"-",
")",
"of",
"a",
"variable",
"name",
"which",
"may",
"cause",
"problems",
"when",
"using",
"with",
"(",
"CF",
"-",
")",
"netCDF",
"based",
"packages",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L123-L143 |
darothen/xbpch | xbpch/util/cf.py | enforce_cf_variable | def enforce_cf_variable(var, mask_and_scale=True):
""" Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Para... | python | def enforce_cf_variable(var, mask_and_scale=True):
""" Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Para... | [
"def",
"enforce_cf_variable",
"(",
"var",
",",
"mask_and_scale",
"=",
"True",
")",
":",
"var",
"=",
"as_variable",
"(",
"var",
")",
"data",
"=",
"var",
".",
"_data",
"# avoid loading by accessing _data instead of data",
"dims",
"=",
"var",
".",
"dims",
"attrs",
... | Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Parameters
----------
var : xarray.Variable
A v... | [
"Given",
"a",
"Variable",
"constructed",
"from",
"GEOS",
"-",
"Chem",
"output",
"enforce",
"CF",
"-",
"compliant",
"metadata",
"and",
"formatting",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L146-L202 |
bitlabstudio/django-multilingual-news | multilingual_news/models.py | NewsEntryManager.published | def published(self, check_language=True, language=None, kwargs=None,
exclude_kwargs=None):
"""
Returns all entries, which publication date has been hit or which have
no date and which language matches the current language.
"""
if check_language:
qs ... | python | def published(self, check_language=True, language=None, kwargs=None,
exclude_kwargs=None):
"""
Returns all entries, which publication date has been hit or which have
no date and which language matches the current language.
"""
if check_language:
qs ... | [
"def",
"published",
"(",
"self",
",",
"check_language",
"=",
"True",
",",
"language",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"exclude_kwargs",
"=",
"None",
")",
":",
"if",
"check_language",
":",
"qs",
"=",
"NewsEntry",
".",
"objects",
".",
"langua... | Returns all entries, which publication date has been hit or which have
no date and which language matches the current language. | [
"Returns",
"all",
"entries",
"which",
"publication",
"date",
"has",
"been",
"hit",
"or",
"which",
"have",
"no",
"date",
"and",
"which",
"language",
"matches",
"the",
"current",
"language",
"."
] | train | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/models.py#L100-L119 |
bitlabstudio/django-multilingual-news | multilingual_news/models.py | NewsEntryManager.recent | def recent(self, check_language=True, language=None, limit=3, exclude=None,
kwargs=None, category=None):
"""
Returns recently published new entries.
"""
if category:
if not kwargs:
kwargs = {}
kwargs['categories__in'] = [category]
... | python | def recent(self, check_language=True, language=None, limit=3, exclude=None,
kwargs=None, category=None):
"""
Returns recently published new entries.
"""
if category:
if not kwargs:
kwargs = {}
kwargs['categories__in'] = [category]
... | [
"def",
"recent",
"(",
"self",
",",
"check_language",
"=",
"True",
",",
"language",
"=",
"None",
",",
"limit",
"=",
"3",
",",
"exclude",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"if",
"category",
":",
"if",
"n... | Returns recently published new entries. | [
"Returns",
"recently",
"published",
"new",
"entries",
"."
] | train | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/models.py#L121-L135 |
bitlabstudio/django-multilingual-news | multilingual_news/templatetags/multilingual_news_tags.py | get_newsentry_meta_description | def get_newsentry_meta_description(newsentry):
"""Returns the meta description for the given entry."""
if newsentry.meta_description:
return newsentry.meta_description
# If there is no seo addon found, take the info from the placeholders
text = newsentry.get_description()
if len(text) > 16... | python | def get_newsentry_meta_description(newsentry):
"""Returns the meta description for the given entry."""
if newsentry.meta_description:
return newsentry.meta_description
# If there is no seo addon found, take the info from the placeholders
text = newsentry.get_description()
if len(text) > 16... | [
"def",
"get_newsentry_meta_description",
"(",
"newsentry",
")",
":",
"if",
"newsentry",
".",
"meta_description",
":",
"return",
"newsentry",
".",
"meta_description",
"# If there is no seo addon found, take the info from the placeholders",
"text",
"=",
"newsentry",
".",
"get_d... | Returns the meta description for the given entry. | [
"Returns",
"the",
"meta",
"description",
"for",
"the",
"given",
"entry",
"."
] | train | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/templatetags/multilingual_news_tags.py#L19-L29 |
bitlabstudio/django-multilingual-news | multilingual_news/templatetags/multilingual_news_tags.py | render_news_placeholder | def render_news_placeholder(context, obj, name=False, truncate=False): # pragma: nocover # NOQA
"""
DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render... | python | def render_news_placeholder(context, obj, name=False, truncate=False): # pragma: nocover # NOQA
"""
DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render... | [
"def",
"render_news_placeholder",
"(",
"context",
",",
"obj",
",",
"name",
"=",
"False",
",",
"truncate",
"=",
"False",
")",
":",
"# pragma: nocover # NOQA",
"warnings",
".",
"warn",
"(",
"\"render_news_placeholder is deprecated. Use render_placeholder\"",
"\" instead\""... | DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render_placeholder`` tag. | [
"DEPRECATED",
":",
"Template",
"tag",
"to",
"render",
"a",
"placeholder",
"from",
"an",
"NewsEntry",
"object"
] | train | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/templatetags/multilingual_news_tags.py#L55-L93 |
openSUSE/py2pack | py2pack/requires.py | _requirement_filter_by_marker | def _requirement_filter_by_marker(req):
# type: (pkg_resources.Requirement) -> bool
"""Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system ... | python | def _requirement_filter_by_marker(req):
# type: (pkg_resources.Requirement) -> bool
"""Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system ... | [
"def",
"_requirement_filter_by_marker",
"(",
"req",
")",
":",
"# type: (pkg_resources.Requirement) -> bool",
"if",
"hasattr",
"(",
"req",
",",
"'marker'",
")",
"and",
"req",
".",
"marker",
":",
"marker_env",
"=",
"{",
"'python_version'",
":",
"'.'",
".",
"join",
... | Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system platform are checked. | [
"Check",
"if",
"the",
"requirement",
"is",
"satisfied",
"by",
"the",
"marker",
"."
] | train | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L37-L52 |
openSUSE/py2pack | py2pack/requires.py | _requirement_find_lowest_possible | def _requirement_find_lowest_possible(req):
# type: (pkg_resources.Requirement) -> List[str]
"""Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be... | python | def _requirement_find_lowest_possible(req):
# type: (pkg_resources.Requirement) -> List[str]
"""Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be... | [
"def",
"_requirement_find_lowest_possible",
"(",
"req",
")",
":",
"# type: (pkg_resources.Requirement) -> List[str]",
"version_dep",
"=",
"None",
"# type: Optional[str]",
"version_comp",
"=",
"None",
"# type: Optional[str]",
"for",
"dep",
"in",
"req",
".",
"specs",
":",
"... | Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be used as the minimal supported version.
Examples
--------
>>> req = pkg_resources.Requirem... | [
"Find",
"lowest",
"required",
"version",
"."
] | train | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L55-L93 |
openSUSE/py2pack | py2pack/requires.py | _requirements_sanitize | def _requirements_sanitize(req_list):
# type: (List[str]) -> List[str]
"""
Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
... | python | def _requirements_sanitize(req_list):
# type: (List[str]) -> List[str]
"""
Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
... | [
"def",
"_requirements_sanitize",
"(",
"req_list",
")",
":",
"# type: (List[str]) -> List[str]",
"filtered_req_list",
"=",
"(",
"_requirement_find_lowest_possible",
"(",
"req",
")",
"for",
"req",
"in",
"(",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"s",
... | Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
>>> _requirements_sanitize([
... 'foo>=3.0',
... "monotonic>=1.0,>0.1;p... | [
"Cleanup",
"a",
"list",
"of",
"requirement",
"strings",
"(",
"e",
".",
"g",
".",
"from",
"requirements",
".",
"txt",
")",
"to",
"only",
"contain",
"entries",
"valid",
"for",
"this",
"platform",
"and",
"with",
"the",
"lowest",
"required",
"version",
"only",... | train | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L96-L119 |
madedotcom/atomicpuppy | atomicpuppy/atomicpuppy.py | _ensure_coroutine_function | def _ensure_coroutine_function(func):
"""Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine!
"""
if asyncio.iscoroutinefunction(func):
return func
else:
@asyncio.coroutine
def coroutine_funct... | python | def _ensure_coroutine_function(func):
"""Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine!
"""
if asyncio.iscoroutinefunction(func):
return func
else:
@asyncio.coroutine
def coroutine_funct... | [
"def",
"_ensure_coroutine_function",
"(",
"func",
")",
":",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"func",
")",
":",
"return",
"func",
"else",
":",
"@",
"asyncio",
".",
"coroutine",
"def",
"coroutine_function",
"(",
"evt",
")",
":",
"func",
"(",
... | Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine! | [
"Return",
"a",
"coroutine",
"function",
"."
] | train | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L481-L495 |
madedotcom/atomicpuppy | atomicpuppy/atomicpuppy.py | Event.location | def location(self):
"""Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event).
"""
if self._location is None:
... | python | def location(self):
"""Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event).
"""
if self._location is None:
... | [
"def",
"location",
"(",
"self",
")",
":",
"if",
"self",
".",
"_location",
"is",
"None",
":",
"self",
".",
"_location",
"=",
"\"{}/{}-{}\"",
".",
"format",
"(",
"self",
".",
"stream",
",",
"self",
".",
"type",
",",
"self",
".",
"sequence",
",",
")",
... | Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event). | [
"Return",
"a",
"string",
"uniquely",
"identifying",
"the",
"event",
"."
] | train | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L74-L87 |
madedotcom/atomicpuppy | atomicpuppy/atomicpuppy.py | EventFinder.find_backwards | async def find_backwards(self, stream_name, predicate, predicate_label='predicate'):
"""Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'.
"""
logger = self._logg... | python | async def find_backwards(self, stream_name, predicate, predicate_label='predicate'):
"""Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'.
"""
logger = self._logg... | [
"async",
"def",
"find_backwards",
"(",
"self",
",",
"stream_name",
",",
"predicate",
",",
"predicate_label",
"=",
"'predicate'",
")",
":",
"logger",
"=",
"self",
".",
"_logger",
".",
"getChild",
"(",
"predicate_label",
")",
"logger",
".",
"info",
"(",
"'Fetc... | Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'. | [
"Return",
"first",
"event",
"matching",
"predicate",
"or",
"None",
"if",
"none",
"exists",
"."
] | train | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L349-L372 |
xolox/python-qpass | qpass/cli.py | main | def main():
"""Command line interface for the ``qpass`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Prepare for command line argument parsing.
action = show_matching_entry
program_opts = dict(exclude_list=[])
show_opts = dict(filters=[], use_clipboard=is_clipboa... | python | def main():
"""Command line interface for the ``qpass`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Prepare for command line argument parsing.
action = show_matching_entry
program_opts = dict(exclude_list=[])
show_opts = dict(filters=[], use_clipboard=is_clipboa... | [
"def",
"main",
"(",
")",
":",
"# Initialize logging to the terminal.",
"coloredlogs",
".",
"install",
"(",
")",
"# Prepare for command line argument parsing.",
"action",
"=",
"show_matching_entry",
"program_opts",
"=",
"dict",
"(",
"exclude_list",
"=",
"[",
"]",
")",
... | Command line interface for the ``qpass`` program. | [
"Command",
"line",
"interface",
"for",
"the",
"qpass",
"program",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L101-L160 |
xolox/python-qpass | qpass/cli.py | edit_matching_entry | def edit_matching_entry(program, arguments):
"""Edit the matching entry."""
entry = program.select_entry(*arguments)
entry.context.execute("pass", "edit", entry.name) | python | def edit_matching_entry(program, arguments):
"""Edit the matching entry."""
entry = program.select_entry(*arguments)
entry.context.execute("pass", "edit", entry.name) | [
"def",
"edit_matching_entry",
"(",
"program",
",",
"arguments",
")",
":",
"entry",
"=",
"program",
".",
"select_entry",
"(",
"*",
"arguments",
")",
"entry",
".",
"context",
".",
"execute",
"(",
"\"pass\"",
",",
"\"edit\"",
",",
"entry",
".",
"name",
")"
] | Edit the matching entry. | [
"Edit",
"the",
"matching",
"entry",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L163-L166 |
xolox/python-qpass | qpass/cli.py | list_matching_entries | def list_matching_entries(program, arguments):
"""List the entries matching the given keywords/patterns."""
output("\n".join(entry.name for entry in program.smart_search(*arguments))) | python | def list_matching_entries(program, arguments):
"""List the entries matching the given keywords/patterns."""
output("\n".join(entry.name for entry in program.smart_search(*arguments))) | [
"def",
"list_matching_entries",
"(",
"program",
",",
"arguments",
")",
":",
"output",
"(",
"\"\\n\"",
".",
"join",
"(",
"entry",
".",
"name",
"for",
"entry",
"in",
"program",
".",
"smart_search",
"(",
"*",
"arguments",
")",
")",
")"
] | List the entries matching the given keywords/patterns. | [
"List",
"the",
"entries",
"matching",
"the",
"given",
"keywords",
"/",
"patterns",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L169-L171 |
xolox/python-qpass | qpass/cli.py | show_matching_entry | def show_matching_entry(program, arguments, use_clipboard=True, quiet=False, filters=()):
"""Show the matching entry on the terminal (and copy the password to the clipboard)."""
entry = program.select_entry(*arguments)
if not quiet:
formatted_entry = entry.format_text(include_password=not use_clipbo... | python | def show_matching_entry(program, arguments, use_clipboard=True, quiet=False, filters=()):
"""Show the matching entry on the terminal (and copy the password to the clipboard)."""
entry = program.select_entry(*arguments)
if not quiet:
formatted_entry = entry.format_text(include_password=not use_clipbo... | [
"def",
"show_matching_entry",
"(",
"program",
",",
"arguments",
",",
"use_clipboard",
"=",
"True",
",",
"quiet",
"=",
"False",
",",
"filters",
"=",
"(",
")",
")",
":",
"entry",
"=",
"program",
".",
"select_entry",
"(",
"*",
"arguments",
")",
"if",
"not",... | Show the matching entry on the terminal (and copy the password to the clipboard). | [
"Show",
"the",
"matching",
"entry",
"on",
"the",
"terminal",
"(",
"and",
"copy",
"the",
"password",
"to",
"the",
"clipboard",
")",
"."
] | train | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L174-L182 |
bkeating/python-payflowpro | payflowpro/classes.py | parse_parameters | def parse_parameters(payflowpro_response_data):
"""
Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will alwa... | python | def parse_parameters(payflowpro_response_data):
"""
Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will alwa... | [
"def",
"parse_parameters",
"(",
"payflowpro_response_data",
")",
":",
"def",
"build_class",
"(",
"klass",
",",
"unconsumed_data",
")",
":",
"known_att_names_set",
"=",
"set",
"(",
"klass",
".",
"base_fields",
".",
"keys",
"(",
")",
")",
"available_atts_set",
"="... | Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will always be the Response object, and
the RecurringPayments obj... | [
"Parses",
"a",
"set",
"of",
"Payflow",
"Pro",
"response",
"parameter",
"name",
"and",
"value",
"pairs",
"into",
"a",
"list",
"of",
"PayflowProObjects",
"and",
"returns",
"a",
"tuple",
"containing",
"the",
"object",
"list",
"and",
"a",
"dictionary",
"containing... | train | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/classes.py#L359-L409 |
WojciechMula/canvas2svg | canvasvg.py | convert | def convert(document, canvas, items=None, tounicode=None):
"""
Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Ret... | python | def convert(document, canvas, items=None, tounicode=None):
"""
Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Ret... | [
"def",
"convert",
"(",
"document",
",",
"canvas",
",",
"items",
"=",
"None",
",",
"tounicode",
"=",
"None",
")",
":",
"tk",
"=",
"canvas",
".",
"tk",
"global",
"segment",
"if",
"items",
"is",
"None",
":",
"# default: all items",
"items",
"=",
"canvas",
... | Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Return list of XML elements | [
"Convert",
"items",
"stored",
"in",
"canvas",
"to",
"SVG",
"document",
".",
"If",
"items",
"is",
"None",
"then",
"all",
"items",
"are",
"convered",
"."
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L73-L315 |
WojciechMula/canvas2svg | canvasvg.py | SVGdocument | def SVGdocument():
"Create default SVG document"
import xml.dom.minidom
implementation = xml.dom.minidom.getDOMImplementation()
doctype = implementation.createDocumentType(
"svg", "-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
)
document= implementation.createDocument(None, "sv... | python | def SVGdocument():
"Create default SVG document"
import xml.dom.minidom
implementation = xml.dom.minidom.getDOMImplementation()
doctype = implementation.createDocumentType(
"svg", "-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
)
document= implementation.createDocument(None, "sv... | [
"def",
"SVGdocument",
"(",
")",
":",
"import",
"xml",
".",
"dom",
".",
"minidom",
"implementation",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"getDOMImplementation",
"(",
")",
"doctype",
"=",
"implementation",
".",
"createDocumentType",
"(",
"\"svg\"",
",... | Create default SVG document | [
"Create",
"default",
"SVG",
"document"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L318-L331 |
WojciechMula/canvas2svg | canvasvg.py | segment_to_line | def segment_to_line(document, coords):
"polyline with 2 vertices using <line> tag"
return setattribs(
document.createElement('line'),
x1 = coords[0],
y1 = coords[1],
x2 = coords[2],
y2 = coords[3],
) | python | def segment_to_line(document, coords):
"polyline with 2 vertices using <line> tag"
return setattribs(
document.createElement('line'),
x1 = coords[0],
y1 = coords[1],
x2 = coords[2],
y2 = coords[3],
) | [
"def",
"segment_to_line",
"(",
"document",
",",
"coords",
")",
":",
"return",
"setattribs",
"(",
"document",
".",
"createElement",
"(",
"'line'",
")",
",",
"x1",
"=",
"coords",
"[",
"0",
"]",
",",
"y1",
"=",
"coords",
"[",
"1",
"]",
",",
"x2",
"=",
... | polyline with 2 vertices using <line> tag | [
"polyline",
"with",
"2",
"vertices",
"using",
"<line",
">",
"tag"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L384-L392 |
WojciechMula/canvas2svg | canvasvg.py | polyline | def polyline(document, coords):
"polyline with more then 2 vertices"
points = []
for i in range(0, len(coords), 2):
points.append("%s,%s" % (coords[i], coords[i+1]))
return setattribs(
document.createElement('polyline'),
points = ' '.join(points),
) | python | def polyline(document, coords):
"polyline with more then 2 vertices"
points = []
for i in range(0, len(coords), 2):
points.append("%s,%s" % (coords[i], coords[i+1]))
return setattribs(
document.createElement('polyline'),
points = ' '.join(points),
) | [
"def",
"polyline",
"(",
"document",
",",
"coords",
")",
":",
"points",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"coords",
")",
",",
"2",
")",
":",
"points",
".",
"append",
"(",
"\"%s,%s\"",
"%",
"(",
"coords",
"[",
"... | polyline with more then 2 vertices | [
"polyline",
"with",
"more",
"then",
"2",
"vertices"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L403-L412 |
WojciechMula/canvas2svg | canvasvg.py | smoothline | def smoothline(document, coords):
"smoothed polyline"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
x0, y0 = points[0]
x1, y1 = points[1]
p0 = (2*x0-x1, 2*y0-y1)
x0, y0 = points[-1]
x1, y1 = points[-2]
... | python | def smoothline(document, coords):
"smoothed polyline"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
x0, y0 = points[0]
x1, y1 = points[1]
p0 = (2*x0-x1, 2*y0-y1)
x0, y0 = points[-1]
x1, y1 = points[-2]
... | [
"def",
"smoothline",
"(",
"document",
",",
"coords",
")",
":",
"element",
"=",
"document",
".",
"createElement",
"(",
"'path'",
")",
"path",
"=",
"[",
"]",
"points",
"=",
"[",
"(",
"coords",
"[",
"i",
"]",
",",
"coords",
"[",
"i",
"+",
"1",
"]",
... | smoothed polyline | [
"smoothed",
"polyline"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L415-L447 |
WojciechMula/canvas2svg | canvasvg.py | cubic_bezier | def cubic_bezier(document, coords):
"cubic bezier polyline"
element = document.createElement('path')
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
path = ["M%s %s" %points[0]]
for n in xrange(1, len(points), 3):
A, B, C = points[n:n+3]
path.append("C%s,%s %s,%s %s,%s" % (A[0], A[1]... | python | def cubic_bezier(document, coords):
"cubic bezier polyline"
element = document.createElement('path')
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
path = ["M%s %s" %points[0]]
for n in xrange(1, len(points), 3):
A, B, C = points[n:n+3]
path.append("C%s,%s %s,%s %s,%s" % (A[0], A[1]... | [
"def",
"cubic_bezier",
"(",
"document",
",",
"coords",
")",
":",
"element",
"=",
"document",
".",
"createElement",
"(",
"'path'",
")",
"points",
"=",
"[",
"(",
"coords",
"[",
"i",
"]",
",",
"coords",
"[",
"i",
"+",
"1",
"]",
")",
"for",
"i",
"in",
... | cubic bezier polyline | [
"cubic",
"bezier",
"polyline"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L449-L458 |
WojciechMula/canvas2svg | canvasvg.py | smoothpolygon | def smoothpolygon(document, coords):
"smoothed filled polygon"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
p = points
n = len(points)
for i in range(0, len(points)):
a = p[(i-1) % n]
b = p[i]
c = p[(i... | python | def smoothpolygon(document, coords):
"smoothed filled polygon"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
p = points
n = len(points)
for i in range(0, len(points)):
a = p[(i-1) % n]
b = p[i]
c = p[(i... | [
"def",
"smoothpolygon",
"(",
"document",
",",
"coords",
")",
":",
"element",
"=",
"document",
".",
"createElement",
"(",
"'path'",
")",
"path",
"=",
"[",
"]",
"points",
"=",
"[",
"(",
"coords",
"[",
"i",
"]",
",",
"coords",
"[",
"i",
"+",
"1",
"]",... | smoothed filled polygon | [
"smoothed",
"filled",
"polygon"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L472-L497 |
WojciechMula/canvas2svg | canvasvg.py | oval | def oval(document, coords):
"circle/ellipse"
x1, y1, x2, y2 = coords
# circle
if x2-x1 == y2-y1:
return setattribs(document.createElement('circle'),
cx = (x1+x2)/2,
cy = (y1+y2)/2,
r = abs(x2-x1)/2,
)
# ellipse
else:
return setattribs(document.createElement('ellipse'),
cx = (x1+x2)/2,
cy ... | python | def oval(document, coords):
"circle/ellipse"
x1, y1, x2, y2 = coords
# circle
if x2-x1 == y2-y1:
return setattribs(document.createElement('circle'),
cx = (x1+x2)/2,
cy = (y1+y2)/2,
r = abs(x2-x1)/2,
)
# ellipse
else:
return setattribs(document.createElement('ellipse'),
cx = (x1+x2)/2,
cy ... | [
"def",
"oval",
"(",
"document",
",",
"coords",
")",
":",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"coords",
"# circle",
"if",
"x2",
"-",
"x1",
"==",
"y2",
"-",
"y1",
":",
"return",
"setattribs",
"(",
"document",
".",
"createElement",
"(",
"'circ... | circle/ellipse | [
"circle",
"/",
"ellipse"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L510-L531 |
WojciechMula/canvas2svg | canvasvg.py | arc | def arc(document, bounding_rect, start, extent, style):
"arc, pieslice (filled), arc with chord (filled)"
(x1, y1, x2, y2) = bounding_rect
import math
cx = (x1 + x2)/2.0
cy = (y1 + y2)/2.0
rx = (x2 - x1)/2.0
ry = (y2 - y1)/2.0
start = math.radians(float(start))
extent = math.radians(float(extent))
# fr... | python | def arc(document, bounding_rect, start, extent, style):
"arc, pieslice (filled), arc with chord (filled)"
(x1, y1, x2, y2) = bounding_rect
import math
cx = (x1 + x2)/2.0
cy = (y1 + y2)/2.0
rx = (x2 - x1)/2.0
ry = (y2 - y1)/2.0
start = math.radians(float(start))
extent = math.radians(float(extent))
# fr... | [
"def",
"arc",
"(",
"document",
",",
"bounding_rect",
",",
"start",
",",
"extent",
",",
"style",
")",
":",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"=",
"bounding_rect",
"import",
"math",
"cx",
"=",
"(",
"x1",
"+",
"x2",
")",
"/",
"2.0",
... | arc, pieslice (filled), arc with chord (filled) | [
"arc",
"pieslice",
"(",
"filled",
")",
"arc",
"with",
"chord",
"(",
"filled",
")"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L534-L581 |
WojciechMula/canvas2svg | canvasvg.py | HTMLcolor | def HTMLcolor(canvas, color):
"returns Tk color in form '#rrggbb' or '#rgb'"
if color:
# r, g, b \in [0..2**16]
r, g, b = ["%02x" % (c // 256) for c in canvas.winfo_rgb(color)]
if (r[0] == r[1]) and (g[0] == g[1]) and (b[0] == b[1]):
# shorter form #rgb
return "#" + r[0] + g[0] + b[0]
else:
return ... | python | def HTMLcolor(canvas, color):
"returns Tk color in form '#rrggbb' or '#rgb'"
if color:
# r, g, b \in [0..2**16]
r, g, b = ["%02x" % (c // 256) for c in canvas.winfo_rgb(color)]
if (r[0] == r[1]) and (g[0] == g[1]) and (b[0] == b[1]):
# shorter form #rgb
return "#" + r[0] + g[0] + b[0]
else:
return ... | [
"def",
"HTMLcolor",
"(",
"canvas",
",",
"color",
")",
":",
"if",
"color",
":",
"# r, g, b \\in [0..2**16]",
"r",
",",
"g",
",",
"b",
"=",
"[",
"\"%02x\"",
"%",
"(",
"c",
"//",
"256",
")",
"for",
"c",
"in",
"canvas",
".",
"winfo_rgb",
"(",
"color",
... | returns Tk color in form '#rrggbb' or '#rgb | [
"returns",
"Tk",
"color",
"in",
"form",
"#rrggbb",
"or",
"#rgb"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L599-L612 |
WojciechMula/canvas2svg | canvasvg.py | arrow_head | def arrow_head(document, x0, y0, x1, y1, arrowshape):
"make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)"
import math
dx = x1 - x0
dy = y1 - y0
poly = document.createElement('polygon')
d = math.sqrt(dx*dx + dy*dy)
if d == 0.0: # XXX: equal, no "close enough"
return poly
try:
d1, d2, d3 = l... | python | def arrow_head(document, x0, y0, x1, y1, arrowshape):
"make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)"
import math
dx = x1 - x0
dy = y1 - y0
poly = document.createElement('polygon')
d = math.sqrt(dx*dx + dy*dy)
if d == 0.0: # XXX: equal, no "close enough"
return poly
try:
d1, d2, d3 = l... | [
"def",
"arrow_head",
"(",
"document",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"arrowshape",
")",
":",
"import",
"math",
"dx",
"=",
"x1",
"-",
"x0",
"dy",
"=",
"y1",
"-",
"y0",
"poly",
"=",
"document",
".",
"createElement",
"(",
"'polygon'"... | make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3) | [
"make",
"arrow",
"head",
"at",
"(",
"x1",
"y1",
")",
"arrowshape",
"is",
"tuple",
"(",
"d1",
"d2",
"d3",
")"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L615-L648 |
WojciechMula/canvas2svg | canvasvg.py | font_actual | def font_actual(tkapp, font):
"actual font parameters"
tmp = tkapp.call('font', 'actual', font)
return dict(
(tmp[i][1:], tmp[i+1]) for i in range(0, len(tmp), 2)
) | python | def font_actual(tkapp, font):
"actual font parameters"
tmp = tkapp.call('font', 'actual', font)
return dict(
(tmp[i][1:], tmp[i+1]) for i in range(0, len(tmp), 2)
) | [
"def",
"font_actual",
"(",
"tkapp",
",",
"font",
")",
":",
"tmp",
"=",
"tkapp",
".",
"call",
"(",
"'font'",
",",
"'actual'",
",",
"font",
")",
"return",
"dict",
"(",
"(",
"tmp",
"[",
"i",
"]",
"[",
"1",
":",
"]",
",",
"tmp",
"[",
"i",
"+",
"1... | actual font parameters | [
"actual",
"font",
"parameters"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L651-L656 |
WojciechMula/canvas2svg | canvasvg.py | parse_dash | def parse_dash(string, width):
"parse dash pattern specified with string"
# DashConvert from {tk-sources}/generic/tkCanvUtil.c
w = max(1, int(width + 0.5))
n = len(string)
result = []
for i, c in enumerate(string):
if c == " " and len(result):
result[-1] += w + 1
elif c == "_":
result.append(8*w)
... | python | def parse_dash(string, width):
"parse dash pattern specified with string"
# DashConvert from {tk-sources}/generic/tkCanvUtil.c
w = max(1, int(width + 0.5))
n = len(string)
result = []
for i, c in enumerate(string):
if c == " " and len(result):
result[-1] += w + 1
elif c == "_":
result.append(8*w)
... | [
"def",
"parse_dash",
"(",
"string",
",",
"width",
")",
":",
"# DashConvert from {tk-sources}/generic/tkCanvUtil.c",
"w",
"=",
"max",
"(",
"1",
",",
"int",
"(",
"width",
"+",
"0.5",
")",
")",
"n",
"=",
"len",
"(",
"string",
")",
"result",
"=",
"[",
"]",
... | parse dash pattern specified with string | [
"parse",
"dash",
"pattern",
"specified",
"with",
"string"
] | train | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L668-L691 |
darothen/xbpch | xbpch/util/gridspec.py | prof_altitude | def prof_altitude(pressure, p_coef=(-0.028389, -0.0493698, 0.485718, 0.278656,
-17.5703, 48.0926)):
"""
Return altitude for given pressure.
This function evaluates a polynomial at log10(pressure) values.
Parameters
----------
pressure : array-like
pr... | python | def prof_altitude(pressure, p_coef=(-0.028389, -0.0493698, 0.485718, 0.278656,
-17.5703, 48.0926)):
"""
Return altitude for given pressure.
This function evaluates a polynomial at log10(pressure) values.
Parameters
----------
pressure : array-like
pr... | [
"def",
"prof_altitude",
"(",
"pressure",
",",
"p_coef",
"=",
"(",
"-",
"0.028389",
",",
"-",
"0.0493698",
",",
"0.485718",
",",
"0.278656",
",",
"-",
"17.5703",
",",
"48.0926",
")",
")",
":",
"pressure",
"=",
"np",
".",
"asarray",
"(",
"pressure",
")",... | Return altitude for given pressure.
This function evaluates a polynomial at log10(pressure) values.
Parameters
----------
pressure : array-like
pressure values [hPa].
p_coef : array-like
coefficients of the polynomial (default values are for the US
Standard Atmosphere).
... | [
"Return",
"altitude",
"for",
"given",
"pressure",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L477-L519 |
darothen/xbpch | xbpch/util/gridspec.py | prof_pressure | def prof_pressure(altitude, z_coef=(1.94170e-9, -5.14580e-7, 4.57018e-5,
-1.55620e-3, -4.61994e-2, 2.99955)):
"""
Return pressure for given altitude.
This function evaluates a polynomial at altitudes values.
Parameters
----------
altitude : array-like
... | python | def prof_pressure(altitude, z_coef=(1.94170e-9, -5.14580e-7, 4.57018e-5,
-1.55620e-3, -4.61994e-2, 2.99955)):
"""
Return pressure for given altitude.
This function evaluates a polynomial at altitudes values.
Parameters
----------
altitude : array-like
... | [
"def",
"prof_pressure",
"(",
"altitude",
",",
"z_coef",
"=",
"(",
"1.94170e-9",
",",
"-",
"5.14580e-7",
",",
"4.57018e-5",
",",
"-",
"1.55620e-3",
",",
"-",
"4.61994e-2",
",",
"2.99955",
")",
")",
":",
"altitude",
"=",
"np",
".",
"asarray",
"(",
"altitud... | Return pressure for given altitude.
This function evaluates a polynomial at altitudes values.
Parameters
----------
altitude : array-like
altitude values [km].
z_coef : array-like
coefficients of the polynomial (default values are for the US
Standard Atmosphere).
Retur... | [
"Return",
"pressure",
"for",
"given",
"altitude",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L522-L564 |
darothen/xbpch | xbpch/util/gridspec.py | _find_references | def _find_references(model_name, references=None):
"""
Iterate over model references for `model_name`
and return a list of parent model specifications (including those of
`model_name`, ordered from parent to child).
"""
references = references or []
references.append(model_name)
ref = M... | python | def _find_references(model_name, references=None):
"""
Iterate over model references for `model_name`
and return a list of parent model specifications (including those of
`model_name`, ordered from parent to child).
"""
references = references or []
references.append(model_name)
ref = M... | [
"def",
"_find_references",
"(",
"model_name",
",",
"references",
"=",
"None",
")",
":",
"references",
"=",
"references",
"or",
"[",
"]",
"references",
".",
"append",
"(",
"model_name",
")",
"ref",
"=",
"MODELS",
"[",
"model_name",
"]",
".",
"get",
"(",
"... | Iterate over model references for `model_name`
and return a list of parent model specifications (including those of
`model_name`, ordered from parent to child). | [
"Iterate",
"over",
"model",
"references",
"for",
"model_name",
"and",
"return",
"a",
"list",
"of",
"parent",
"model",
"specifications",
"(",
"including",
"those",
"of",
"model_name",
"ordered",
"from",
"parent",
"to",
"child",
")",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L575-L591 |
darothen/xbpch | xbpch/util/gridspec.py | _get_model_info | def _get_model_info(model_name):
"""
Get the grid specifications for a given model.
Parameters
----------
model_name : string
Name of the model. Supports multiple formats
(e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5').
Returns
-------
specifications : dict
Grid specifica... | python | def _get_model_info(model_name):
"""
Get the grid specifications for a given model.
Parameters
----------
model_name : string
Name of the model. Supports multiple formats
(e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5').
Returns
-------
specifications : dict
Grid specifica... | [
"def",
"_get_model_info",
"(",
"model_name",
")",
":",
"# trying to get as much as possible a valid model name from the given",
"# `model_name`, using regular expressions.",
"split_name",
"=",
"re",
".",
"split",
"(",
"r'[\\-_\\s]'",
",",
"model_name",
".",
"strip",
"(",
")",... | Get the grid specifications for a given model.
Parameters
----------
model_name : string
Name of the model. Supports multiple formats
(e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5').
Returns
-------
specifications : dict
Grid specifications as a dictionary.
Raises
------... | [
"Get",
"the",
"grid",
"specifications",
"for",
"a",
"given",
"model",
"."
] | train | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L594-L646 |
openSUSE/py2pack | py2pack/utils.py | _get_archive_filelist | def _get_archive_filelist(filename):
# type: (str) -> List[str]
"""Extract the list of files from a tar or zip archive.
Args:
filename: name of the archive
Returns:
Sorted list of files in the archive, excluding './'
Raises:
ValueError: when the file is neither a zip nor a... | python | def _get_archive_filelist(filename):
# type: (str) -> List[str]
"""Extract the list of files from a tar or zip archive.
Args:
filename: name of the archive
Returns:
Sorted list of files in the archive, excluding './'
Raises:
ValueError: when the file is neither a zip nor a... | [
"def",
"_get_archive_filelist",
"(",
"filename",
")",
":",
"# type: (str) -> List[str]",
"names",
"=",
"[",
"]",
"# type: List[str]",
"if",
"tarfile",
".",
"is_tarfile",
"(",
"filename",
")",
":",
"with",
"tarfile",
".",
"open",
"(",
"filename",
")",
"as",
"ta... | Extract the list of files from a tar or zip archive.
Args:
filename: name of the archive
Returns:
Sorted list of files in the archive, excluding './'
Raises:
ValueError: when the file is neither a zip nor a tar archive
FileNotFoundError: when the provided file does not exi... | [
"Extract",
"the",
"list",
"of",
"files",
"from",
"a",
"tar",
"or",
"zip",
"archive",
"."
] | train | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/utils.py#L26-L53 |
Hackerfleet/hfos | modules/library/hfos/library/manager.py | Manager._augment_book | def _augment_book(self, uuid, event):
"""
Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client
"""
try:
if not is... | python | def _augment_book(self, uuid, event):
"""
Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client
"""
try:
if not is... | [
"def",
"_augment_book",
"(",
"self",
",",
"uuid",
",",
"event",
")",
":",
"try",
":",
"if",
"not",
"isbnmeta",
":",
"self",
".",
"log",
"(",
"\"No isbntools found! Install it to get full \"",
"\"functionality!\"",
",",
"lvl",
"=",
"warn",
")",
"return",
"new_b... | Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client | [
"Checks",
"if",
"the",
"newly",
"created",
"object",
"is",
"a",
"book",
"and",
"only",
"has",
"an",
"ISBN",
".",
"If",
"so",
"tries",
"to",
"fetch",
"the",
"book",
"data",
"off",
"the",
"internet",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/library/hfos/library/manager.py#L141-L215 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | serial_ports | def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-p... | python | def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-p... | [
"def",
"serial_ports",
"(",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
":",
"ports",
"=",
"[",
"'COM%s'",
"%",
"(",
"i",
"+",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"256",
")",
"]",
"elif",
"sys",
".",
"pla... | Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-ports-with-python ) | [
"Lists",
"serial",
"port",
"names"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L58-L87 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | Machineroom.opened | def opened(self, *args):
"""Initiates communication with the remote controlled device.
:param args:
"""
self._serial_open = True
self.log("Opened: ", args, lvl=debug)
self._send_command(b'l,1') # Saying hello, shortly
self.log("Turning off engine, pump and neut... | python | def opened(self, *args):
"""Initiates communication with the remote controlled device.
:param args:
"""
self._serial_open = True
self.log("Opened: ", args, lvl=debug)
self._send_command(b'l,1') # Saying hello, shortly
self.log("Turning off engine, pump and neut... | [
"def",
"opened",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"_serial_open",
"=",
"True",
"self",
".",
"log",
"(",
"\"Opened: \"",
",",
"args",
",",
"lvl",
"=",
"debug",
")",
"self",
".",
"_send_command",
"(",
"b'l,1'",
")",
"# Saying hello, ... | Initiates communication with the remote controlled device.
:param args: | [
"Initiates",
"communication",
"with",
"the",
"remote",
"controlled",
"device",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L172-L188 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | Machineroom.on_machinerequest | def on_machinerequest(self, event):
"""
Sets a new machine speed.
:param event:
"""
self.log("Updating new machine power: ", event.controlvalue)
self._handle_servo(self._machine_channel, event.controlvalue) | python | def on_machinerequest(self, event):
"""
Sets a new machine speed.
:param event:
"""
self.log("Updating new machine power: ", event.controlvalue)
self._handle_servo(self._machine_channel, event.controlvalue) | [
"def",
"on_machinerequest",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Updating new machine power: \"",
",",
"event",
".",
"controlvalue",
")",
"self",
".",
"_handle_servo",
"(",
"self",
".",
"_machine_channel",
",",
"event",
".",
"contro... | Sets a new machine speed.
:param event: | [
"Sets",
"a",
"new",
"machine",
"speed",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L221-L228 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | Machineroom.on_rudderrequest | def on_rudderrequest(self, event):
"""
Sets a new rudder angle.
:param event:
"""
self.log("Updating new rudder angle: ", event.controlvalue)
self._handle_servo(self._rudder_channel, event.controlvalue) | python | def on_rudderrequest(self, event):
"""
Sets a new rudder angle.
:param event:
"""
self.log("Updating new rudder angle: ", event.controlvalue)
self._handle_servo(self._rudder_channel, event.controlvalue) | [
"def",
"on_rudderrequest",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Updating new rudder angle: \"",
",",
"event",
".",
"controlvalue",
")",
"self",
".",
"_handle_servo",
"(",
"self",
".",
"_rudder_channel",
",",
"event",
".",
"controlva... | Sets a new rudder angle.
:param event: | [
"Sets",
"a",
"new",
"rudder",
"angle",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L231-L238 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | Machineroom.on_pumprequest | def on_pumprequest(self, event):
"""
Activates or deactivates a connected pump.
:param event:
"""
self.log("Updating pump status: ", event.controlvalue)
self._set_digital_pin(self._pump_channel, event.controlvalue) | python | def on_pumprequest(self, event):
"""
Activates or deactivates a connected pump.
:param event:
"""
self.log("Updating pump status: ", event.controlvalue)
self._set_digital_pin(self._pump_channel, event.controlvalue) | [
"def",
"on_pumprequest",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Updating pump status: \"",
",",
"event",
".",
"controlvalue",
")",
"self",
".",
"_set_digital_pin",
"(",
"self",
".",
"_pump_channel",
",",
"event",
".",
"controlvalue",
... | Activates or deactivates a connected pump.
:param event: | [
"Activates",
"or",
"deactivates",
"a",
"connected",
"pump",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L241-L248 |
Hackerfleet/hfos | hfos/provisions/base.py | provisionList | def provisionList(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provisions a list of items according to their schema
:param items: A list of provisionable items.
:param database_object: A warmongo database object
:param overwrite: Causes existing items to be overwritten... | python | def provisionList(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provisions a list of items according to their schema
:param items: A list of provisionable items.
:param database_object: A warmongo database object
:param overwrite: Causes existing items to be overwritten... | [
"def",
"provisionList",
"(",
"items",
",",
"database_name",
",",
"overwrite",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"skip_user_check",
"=",
"False",
")",
":",
"log",
"(",
"'Provisioning'",
",",
"items",
",",
"database_name",
",",
"lvl",
"=",
"debu... | Provisions a list of items according to their schema
:param items: A list of provisionable items.
:param database_object: A warmongo database object
:param overwrite: Causes existing items to be overwritten
:param clear: Clears the collection first (Danger!)
:param skip_user_check: Skips checking i... | [
"Provisions",
"a",
"list",
"of",
"items",
"according",
"to",
"their",
"schema"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/base.py#L48-L148 |
Hackerfleet/hfos | hfos/schemata/extends.py | DefaultExtension | def DefaultExtension(schema_obj, form_obj, schemata=None):
"""Create a default field"""
if schemata is None:
schemata = ['systemconfig', 'profile', 'client']
DefaultExtends = {
'schema': {
"properties/modules": [
schema_obj
]
},
'form... | python | def DefaultExtension(schema_obj, form_obj, schemata=None):
"""Create a default field"""
if schemata is None:
schemata = ['systemconfig', 'profile', 'client']
DefaultExtends = {
'schema': {
"properties/modules": [
schema_obj
]
},
'form... | [
"def",
"DefaultExtension",
"(",
"schema_obj",
",",
"form_obj",
",",
"schemata",
"=",
"None",
")",
":",
"if",
"schemata",
"is",
"None",
":",
"schemata",
"=",
"[",
"'systemconfig'",
",",
"'profile'",
",",
"'client'",
"]",
"DefaultExtends",
"=",
"{",
"'schema'"... | Create a default field | [
"Create",
"a",
"default",
"field"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/extends.py#L25-L49 |
Hackerfleet/hfos | hfos/ui/builder.py | copytree | def copytree(root_src_dir, root_dst_dir, hardlink=True):
"""Copies a whole directory tree"""
for src_dir, dirs, files in os.walk(root_src_dir):
dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
for file_ in files:
... | python | def copytree(root_src_dir, root_dst_dir, hardlink=True):
"""Copies a whole directory tree"""
for src_dir, dirs, files in os.walk(root_src_dir):
dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
for file_ in files:
... | [
"def",
"copytree",
"(",
"root_src_dir",
",",
"root_dst_dir",
",",
"hardlink",
"=",
"True",
")",
":",
"for",
"src_dir",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root_src_dir",
")",
":",
"dst_dir",
"=",
"src_dir",
".",
"replace",
"(",
"r... | Copies a whole directory tree | [
"Copies",
"a",
"whole",
"directory",
"tree"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/builder.py#L41-L79 |
Hackerfleet/hfos | hfos/ui/builder.py | install_frontend | def install_frontend(instance='default', forcereload=False, forcerebuild=False,
forcecopy=True, install=True, development=False, build_type='dist'):
"""Builds and installs the frontend"""
hfoslog("Updating frontend components", emitter='BUILDER')
components = {}
loadable_components... | python | def install_frontend(instance='default', forcereload=False, forcerebuild=False,
forcecopy=True, install=True, development=False, build_type='dist'):
"""Builds and installs the frontend"""
hfoslog("Updating frontend components", emitter='BUILDER')
components = {}
loadable_components... | [
"def",
"install_frontend",
"(",
"instance",
"=",
"'default'",
",",
"forcereload",
"=",
"False",
",",
"forcerebuild",
"=",
"False",
",",
"forcecopy",
"=",
"True",
",",
"install",
"=",
"True",
",",
"development",
"=",
"False",
",",
"build_type",
"=",
"'dist'",... | Builds and installs the frontend | [
"Builds",
"and",
"installs",
"the",
"frontend"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/builder.py#L83-L281 |
Hackerfleet/hfos | hfos/tool/configuration.py | config | def config(ctx):
"""[GROUP] Configuration management operations"""
from hfos import database
database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
from hfos.schemata.component import ComponentConfigSchemaTemplate
ctx.obj['col'] = model_factory(ComponentConfigSchemaTemplate) | python | def config(ctx):
"""[GROUP] Configuration management operations"""
from hfos import database
database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
from hfos.schemata.component import ComponentConfigSchemaTemplate
ctx.obj['col'] = model_factory(ComponentConfigSchemaTemplate) | [
"def",
"config",
"(",
"ctx",
")",
":",
"from",
"hfos",
"import",
"database",
"database",
".",
"initialize",
"(",
"ctx",
".",
"obj",
"[",
"'dbhost'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'dbname'",
"]",
")",
"from",
"hfos",
".",
"schemata",
".",
"compon... | [GROUP] Configuration management operations | [
"[",
"GROUP",
"]",
"Configuration",
"management",
"operations"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L35-L42 |
Hackerfleet/hfos | hfos/tool/configuration.py | delete | def delete(ctx, componentname):
"""Delete an existing component configuration. This will trigger
the creation of its default configuration upon next restart."""
col = ctx.obj['col']
if col.count({'name': componentname}) > 1:
log('More than one component configuration of this name! Try '
... | python | def delete(ctx, componentname):
"""Delete an existing component configuration. This will trigger
the creation of its default configuration upon next restart."""
col = ctx.obj['col']
if col.count({'name': componentname}) > 1:
log('More than one component configuration of this name! Try '
... | [
"def",
"delete",
"(",
"ctx",
",",
"componentname",
")",
":",
"col",
"=",
"ctx",
".",
"obj",
"[",
"'col'",
"]",
"if",
"col",
".",
"count",
"(",
"{",
"'name'",
":",
"componentname",
"}",
")",
">",
"1",
":",
"log",
"(",
"'More than one component configura... | Delete an existing component configuration. This will trigger
the creation of its default configuration upon next restart. | [
"Delete",
"an",
"existing",
"component",
"configuration",
".",
"This",
"will",
"trigger",
"the",
"creation",
"of",
"its",
"default",
"configuration",
"upon",
"next",
"restart",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L48-L73 |
Hackerfleet/hfos | hfos/tool/configuration.py | show | def show(ctx, component):
"""Show the stored, active configuration of a component."""
col = ctx.obj['col']
if col.count({'name': component}) > 1:
log('More than one component configuration of this name! Try '
'one of the uuids as argument. Get a list with "config '
'list"')... | python | def show(ctx, component):
"""Show the stored, active configuration of a component."""
col = ctx.obj['col']
if col.count({'name': component}) > 1:
log('More than one component configuration of this name! Try '
'one of the uuids as argument. Get a list with "config '
'list"')... | [
"def",
"show",
"(",
"ctx",
",",
"component",
")",
":",
"col",
"=",
"ctx",
".",
"obj",
"[",
"'col'",
"]",
"if",
"col",
".",
"count",
"(",
"{",
"'name'",
":",
"component",
"}",
")",
">",
"1",
":",
"log",
"(",
"'More than one component configuration of th... | Show the stored, active configuration of a component. | [
"Show",
"the",
"stored",
"active",
"configuration",
"of",
"a",
"component",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L79-L106 |
andychase/reparse | reparse/util.py | separate_string | def separate_string(string):
"""
>>> separate_string("test <2>")
(['test ', ''], ['2'])
"""
string_list = regex.split(r'<(?![!=])', regex.sub(r'>', '<', string))
return string_list[::2], string_list[1::2] | python | def separate_string(string):
"""
>>> separate_string("test <2>")
(['test ', ''], ['2'])
"""
string_list = regex.split(r'<(?![!=])', regex.sub(r'>', '<', string))
return string_list[::2], string_list[1::2] | [
"def",
"separate_string",
"(",
"string",
")",
":",
"string_list",
"=",
"regex",
".",
"split",
"(",
"r'<(?![!=])'",
",",
"regex",
".",
"sub",
"(",
"r'>'",
",",
"'<'",
",",
"string",
")",
")",
"return",
"string_list",
"[",
":",
":",
"2",
"]",
",",
"str... | >>> separate_string("test <2>")
(['test ', ''], ['2']) | [
">>>",
"separate_string",
"(",
"test",
"<2",
">",
")",
"(",
"[",
"test",
"]",
"[",
"2",
"]",
")"
] | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L3-L9 |
andychase/reparse | reparse/util.py | overlapping | def overlapping(start1, end1, start2, end2):
"""
>>> overlapping(0, 5, 6, 7)
False
>>> overlapping(1, 2, 0, 4)
True
>>> overlapping(5,6,0,5)
False
"""
return not ((start1 <= start2 and start1 <= end2 and end1 <= end2 and end1 <= start2) or
(start1 >= start2 and start1... | python | def overlapping(start1, end1, start2, end2):
"""
>>> overlapping(0, 5, 6, 7)
False
>>> overlapping(1, 2, 0, 4)
True
>>> overlapping(5,6,0,5)
False
"""
return not ((start1 <= start2 and start1 <= end2 and end1 <= end2 and end1 <= start2) or
(start1 >= start2 and start1... | [
"def",
"overlapping",
"(",
"start1",
",",
"end1",
",",
"start2",
",",
"end2",
")",
":",
"return",
"not",
"(",
"(",
"start1",
"<=",
"start2",
"and",
"start1",
"<=",
"end2",
"and",
"end1",
"<=",
"end2",
"and",
"end1",
"<=",
"start2",
")",
"or",
"(",
... | >>> overlapping(0, 5, 6, 7)
False
>>> overlapping(1, 2, 0, 4)
True
>>> overlapping(5,6,0,5)
False | [
">>>",
"overlapping",
"(",
"0",
"5",
"6",
"7",
")",
"False",
">>>",
"overlapping",
"(",
"1",
"2",
"0",
"4",
")",
"True",
">>>",
"overlapping",
"(",
"5",
"6",
"0",
"5",
")",
"False"
] | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L12-L22 |
andychase/reparse | reparse/util.py | remove_lower_overlapping | def remove_lower_overlapping(current, higher):
"""
>>> remove_lower_overlapping([], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)])
[('z', 5, 6), ('a', 0, 5)]
"""
for (mat... | python | def remove_lower_overlapping(current, higher):
"""
>>> remove_lower_overlapping([], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)])
[('z', 5, 6), ('a', 0, 5)]
"""
for (mat... | [
"def",
"remove_lower_overlapping",
"(",
"current",
",",
"higher",
")",
":",
"for",
"(",
"match",
",",
"h_start",
",",
"h_end",
")",
"in",
"higher",
":",
"overlaps",
"=",
"list",
"(",
"overlapping_at",
"(",
"h_start",
",",
"h_end",
",",
"current",
")",
")... | >>> remove_lower_overlapping([], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)])
[('a', 0, 5)]
>>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)])
[('z', 5, 6), ('a', 0, 5)] | [
">>>",
"remove_lower_overlapping",
"(",
"[]",
"[",
"(",
"a",
"0",
"5",
")",
"]",
")",
"[",
"(",
"a",
"0",
"5",
")",
"]",
">>>",
"remove_lower_overlapping",
"(",
"[",
"(",
"z",
"0",
"4",
")",
"]",
"[",
"(",
"a",
"0",
"5",
")",
"]",
")",
"[",
... | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L31-L50 |
Hackerfleet/hfos | hfos/debugger.py | HFDebugger.debugrequest | def debugrequest(self, event):
"""Handler for client-side debug requests"""
try:
self.log("Event: ", event.__dict__, lvl=critical)
if event.data == "storejson":
self.log("Storing received object to /tmp", lvl=critical)
fp = open('/tmp/hfosdebugger... | python | def debugrequest(self, event):
"""Handler for client-side debug requests"""
try:
self.log("Event: ", event.__dict__, lvl=critical)
if event.data == "storejson":
self.log("Storing received object to /tmp", lvl=critical)
fp = open('/tmp/hfosdebugger... | [
"def",
"debugrequest",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"\"Event: \"",
",",
"event",
".",
"__dict__",
",",
"lvl",
"=",
"critical",
")",
"if",
"event",
".",
"data",
"==",
"\"storejson\"",
":",
"self",
".",
"log... | Handler for client-side debug requests | [
"Handler",
"for",
"client",
"-",
"side",
"debug",
"requests"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L223-L264 |
Hackerfleet/hfos | hfos/debugger.py | CLI.stdin_read | def stdin_read(self, data):
"""read Event (on channel ``stdin``)
This is the event handler for ``read`` events specifically from the
``stdin`` channel. This is triggered each time stdin has data that
it has read.
"""
data = data.strip().decode("utf-8")
self.log("... | python | def stdin_read(self, data):
"""read Event (on channel ``stdin``)
This is the event handler for ``read`` events specifically from the
``stdin`` channel. This is triggered each time stdin has data that
it has read.
"""
data = data.strip().decode("utf-8")
self.log("... | [
"def",
"stdin_read",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"data",
".",
"strip",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
"self",
".",
"log",
"(",
"\"Incoming:\"",
",",
"data",
",",
"lvl",
"=",
"verbose",
")",
"if",
"len",
"(",
... | read Event (on channel ``stdin``)
This is the event handler for ``read`` events specifically from the
``stdin`` channel. This is triggered each time stdin has data that
it has read. | [
"read",
"Event",
"(",
"on",
"channel",
"stdin",
")",
"This",
"is",
"the",
"event",
"handler",
"for",
"read",
"events",
"specifically",
"from",
"the",
"stdin",
"channel",
".",
"This",
"is",
"triggered",
"each",
"time",
"stdin",
"has",
"data",
"that",
"it",
... | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L284-L320 |
Hackerfleet/hfos | hfos/debugger.py | CLI.register_event | def register_event(self, event):
"""Registers a new command line interface event hook as command"""
self.log('Registering event hook:', event.cmd, event.thing,
pretty=True, lvl=verbose)
self.hooks[event.cmd] = event.thing | python | def register_event(self, event):
"""Registers a new command line interface event hook as command"""
self.log('Registering event hook:', event.cmd, event.thing,
pretty=True, lvl=verbose)
self.hooks[event.cmd] = event.thing | [
"def",
"register_event",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Registering event hook:'",
",",
"event",
".",
"cmd",
",",
"event",
".",
"thing",
",",
"pretty",
"=",
"True",
",",
"lvl",
"=",
"verbose",
")",
"self",
".",
"hooks",... | Registers a new command line interface event hook as command | [
"Registers",
"a",
"new",
"command",
"line",
"interface",
"event",
"hook",
"as",
"command"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L348-L353 |
Hackerfleet/hfos | hfos/events/system.py | populate_user_events | def populate_user_events():
"""Generate a list of all registered authorized and anonymous events"""
global AuthorizedEvents
global AnonymousEvents
def inheritors(klass):
"""Find inheritors of a specified object class"""
subclasses = {}
subclasses_set = set()
work = [kl... | python | def populate_user_events():
"""Generate a list of all registered authorized and anonymous events"""
global AuthorizedEvents
global AnonymousEvents
def inheritors(klass):
"""Find inheritors of a specified object class"""
subclasses = {}
subclasses_set = set()
work = [kl... | [
"def",
"populate_user_events",
"(",
")",
":",
"global",
"AuthorizedEvents",
"global",
"AnonymousEvents",
"def",
"inheritors",
"(",
"klass",
")",
":",
"\"\"\"Find inheritors of a specified object class\"\"\"",
"subclasses",
"=",
"{",
"}",
"subclasses_set",
"=",
"set",
"(... | Generate a list of all registered authorized and anonymous events | [
"Generate",
"a",
"list",
"of",
"all",
"registered",
"authorized",
"and",
"anonymous",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/events/system.py#L57-L100 |
Hackerfleet/hfos | hfos/tool/database.py | db | def db(ctx):
"""[GROUP] Database management operations"""
from hfos import database
database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
ctx.obj['db'] = database | python | def db(ctx):
"""[GROUP] Database management operations"""
from hfos import database
database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
ctx.obj['db'] = database | [
"def",
"db",
"(",
"ctx",
")",
":",
"from",
"hfos",
"import",
"database",
"database",
".",
"initialize",
"(",
"ctx",
".",
"obj",
"[",
"'dbhost'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'dbname'",
"]",
")",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"=",
"da... | [GROUP] Database management operations | [
"[",
"GROUP",
"]",
"Database",
"management",
"operations"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/database.py#L37-L42 |
Hackerfleet/hfos | hfos/tool/database.py | clear | def clear(ctx, schema):
"""Clears an entire database collection irrevocably. Use with caution!"""
response = _ask('Are you sure you want to delete the collection "%s"' % (
schema), default='N', data_type='bool')
if response is True:
host, port = ctx.obj['dbhost'].split(':')
client ... | python | def clear(ctx, schema):
"""Clears an entire database collection irrevocably. Use with caution!"""
response = _ask('Are you sure you want to delete the collection "%s"' % (
schema), default='N', data_type='bool')
if response is True:
host, port = ctx.obj['dbhost'].split(':')
client ... | [
"def",
"clear",
"(",
"ctx",
",",
"schema",
")",
":",
"response",
"=",
"_ask",
"(",
"'Are you sure you want to delete the collection \"%s\"'",
"%",
"(",
"schema",
")",
",",
"default",
"=",
"'N'",
",",
"data_type",
"=",
"'bool'",
")",
"if",
"response",
"is",
"... | Clears an entire database collection irrevocably. Use with caution! | [
"Clears",
"an",
"entire",
"database",
"collection",
"irrevocably",
".",
"Use",
"with",
"caution!"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/database.py#L94-L112 |
Hackerfleet/hfos | hfos/provisions/system.py | provision_system_config | def provision_system_config(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provision a basic system configuration"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
default_system_config_count = objectmodels['systemconfig'].count({
... | python | def provision_system_config(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provision a basic system configuration"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
default_system_config_count = objectmodels['systemconfig'].count({
... | [
"def",
"provision_system_config",
"(",
"items",
",",
"database_name",
",",
"overwrite",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"skip_user_check",
"=",
"False",
")",
":",
"from",
"hfos",
".",
"provisions",
".",
"base",
"import",
"provisionList",
"from",... | Provision a basic system configuration | [
"Provision",
"a",
"basic",
"system",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/system.py#L50-L64 |
Hackerfleet/hfos | modules/calendar/hfos/calendar/importer/ical.py | ICALImporter | def ICALImporter(ctx, filename, all, owner, calendar, create_calendar, clear_calendar, dry, execfilter):
"""Calendar Importer for iCal (ics) files
"""
log('iCal importer running')
objectmodels = ctx.obj['db'].objectmodels
if objectmodels['user'].count({'name': owner}) > 0:
owner_object =... | python | def ICALImporter(ctx, filename, all, owner, calendar, create_calendar, clear_calendar, dry, execfilter):
"""Calendar Importer for iCal (ics) files
"""
log('iCal importer running')
objectmodels = ctx.obj['db'].objectmodels
if objectmodels['user'].count({'name': owner}) > 0:
owner_object =... | [
"def",
"ICALImporter",
"(",
"ctx",
",",
"filename",
",",
"all",
",",
"owner",
",",
"calendar",
",",
"create_calendar",
",",
"clear_calendar",
",",
"dry",
",",
"execfilter",
")",
":",
"log",
"(",
"'iCal importer running'",
")",
"objectmodels",
"=",
"ctx",
"."... | Calendar Importer for iCal (ics) files | [
"Calendar",
"Importer",
"for",
"iCal",
"(",
"ics",
")",
"files"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/calendar/hfos/calendar/importer/ical.py#L28-L148 |
Hackerfleet/hfos | hfos/migration.py | make_migrations | def make_migrations(schema=None):
"""Create migration data for a specified schema"""
entrypoints = {}
old = {}
def apply_migrations(migrations, new_model):
"""Apply migration data to compile an up to date model"""
def get_path(raw_path):
"""Get local path of schema definit... | python | def make_migrations(schema=None):
"""Create migration data for a specified schema"""
entrypoints = {}
old = {}
def apply_migrations(migrations, new_model):
"""Apply migration data to compile an up to date model"""
def get_path(raw_path):
"""Get local path of schema definit... | [
"def",
"make_migrations",
"(",
"schema",
"=",
"None",
")",
":",
"entrypoints",
"=",
"{",
"}",
"old",
"=",
"{",
"}",
"def",
"apply_migrations",
"(",
"migrations",
",",
"new_model",
")",
":",
"\"\"\"Apply migration data to compile an up to date model\"\"\"",
"def",
... | Create migration data for a specified schema | [
"Create",
"migration",
"data",
"for",
"a",
"specified",
"schema"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/migration.py#L48-L227 |
Hackerfleet/hfos | modules/chat/hfos/chat/host.py | Host.userlogin | def userlogin(self, event):
"""Provides the newly authenticated user with a backlog and general
channel status information"""
try:
user_uuid = event.useruuid
user = objectmodels['user'].find_one({'uuid': user_uuid})
if user_uuid not in self.lastlogs:
... | python | def userlogin(self, event):
"""Provides the newly authenticated user with a backlog and general
channel status information"""
try:
user_uuid = event.useruuid
user = objectmodels['user'].find_one({'uuid': user_uuid})
if user_uuid not in self.lastlogs:
... | [
"def",
"userlogin",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"user_uuid",
"=",
"event",
".",
"useruuid",
"user",
"=",
"objectmodels",
"[",
"'user'",
"]",
".",
"find_one",
"(",
"{",
"'uuid'",
":",
"user_uuid",
"}",
")",
"if",
"user_uuid",
"not",... | Provides the newly authenticated user with a backlog and general
channel status information | [
"Provides",
"the",
"newly",
"authenticated",
"user",
"with",
"a",
"backlog",
"and",
"general",
"channel",
"status",
"information"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L163-L185 |
Hackerfleet/hfos | modules/chat/hfos/chat/host.py | Host.join | def join(self, event):
"""Chat event handler for incoming events
:param event: say-event with incoming chat message
"""
try:
channel_uuid = event.data
user_uuid = event.user.uuid
if channel_uuid in self.chat_channels:
self.log('User j... | python | def join(self, event):
"""Chat event handler for incoming events
:param event: say-event with incoming chat message
"""
try:
channel_uuid = event.data
user_uuid = event.user.uuid
if channel_uuid in self.chat_channels:
self.log('User j... | [
"def",
"join",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"channel_uuid",
"=",
"event",
".",
"data",
"user_uuid",
"=",
"event",
".",
"user",
".",
"uuid",
"if",
"channel_uuid",
"in",
"self",
".",
"chat_channels",
":",
"self",
".",
"log",
"(",
"'... | Chat event handler for incoming events
:param event: say-event with incoming chat message | [
"Chat",
"event",
"handler",
"for",
"incoming",
"events",
":",
"param",
"event",
":",
"say",
"-",
"event",
"with",
"incoming",
"chat",
"message"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L267-L292 |
Hackerfleet/hfos | modules/chat/hfos/chat/host.py | Host.say | def say(self, event):
"""Chat event handler for incoming events
:param event: say-event with incoming chat message
"""
try:
userid = event.user.uuid
recipient = self._get_recipient(event)
content = self._get_content(event)
message = objec... | python | def say(self, event):
"""Chat event handler for incoming events
:param event: say-event with incoming chat message
"""
try:
userid = event.user.uuid
recipient = self._get_recipient(event)
content = self._get_content(event)
message = objec... | [
"def",
"say",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"userid",
"=",
"event",
".",
"user",
".",
"uuid",
"recipient",
"=",
"self",
".",
"_get_recipient",
"(",
"event",
")",
"content",
"=",
"self",
".",
"_get_content",
"(",
"event",
")",
"mess... | Chat event handler for incoming events
:param event: say-event with incoming chat message | [
"Chat",
"event",
"handler",
"for",
"incoming",
"events",
":",
"param",
"event",
":",
"say",
"-",
"event",
"with",
"incoming",
"chat",
"message"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L350-L387 |
Hackerfleet/hfos | hfos/tool/installer.py | install_docs | def install_docs(instance, clear_target):
"""Builds and installs the complete HFOS documentation."""
_check_root()
def make_docs():
"""Trigger a Sphinx make command to build the documentation."""
log("Generating HTML documentation")
try:
build = Popen(
... | python | def install_docs(instance, clear_target):
"""Builds and installs the complete HFOS documentation."""
_check_root()
def make_docs():
"""Trigger a Sphinx make command to build the documentation."""
log("Generating HTML documentation")
try:
build = Popen(
... | [
"def",
"install_docs",
"(",
"instance",
",",
"clear_target",
")",
":",
"_check_root",
"(",
")",
"def",
"make_docs",
"(",
")",
":",
"\"\"\"Trigger a Sphinx make command to build the documentation.\"\"\"",
"log",
"(",
"\"Generating HTML documentation\"",
")",
"try",
":",
... | Builds and installs the complete HFOS documentation. | [
"Builds",
"and",
"installs",
"the",
"complete",
"HFOS",
"documentation",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L67-L115 |
Hackerfleet/hfos | hfos/tool/installer.py | var | def var(ctx, clear_target, clear_all):
"""Install variable data to /var/[lib,cache]/hfos"""
install_var(str(ctx.obj['instance']), clear_target, clear_all) | python | def var(ctx, clear_target, clear_all):
"""Install variable data to /var/[lib,cache]/hfos"""
install_var(str(ctx.obj['instance']), clear_target, clear_all) | [
"def",
"var",
"(",
"ctx",
",",
"clear_target",
",",
"clear_all",
")",
":",
"install_var",
"(",
"str",
"(",
"ctx",
".",
"obj",
"[",
"'instance'",
"]",
")",
",",
"clear_target",
",",
"clear_all",
")"
] | Install variable data to /var/[lib,cache]/hfos | [
"Install",
"variable",
"data",
"to",
"/",
"var",
"/",
"[",
"lib",
"cache",
"]",
"/",
"hfos"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L124-L127 |
Hackerfleet/hfos | hfos/tool/installer.py | install_var | def install_var(instance, clear_target, clear_all):
"""Install required folders in /var"""
_check_root()
log("Checking frontend library and cache directories",
emitter='MANAGE')
uid = pwd.getpwnam("hfos").pw_uid
gid = grp.getgrnam("hfos").gr_gid
join = os.path.join
# If these nee... | python | def install_var(instance, clear_target, clear_all):
"""Install required folders in /var"""
_check_root()
log("Checking frontend library and cache directories",
emitter='MANAGE')
uid = pwd.getpwnam("hfos").pw_uid
gid = grp.getgrnam("hfos").gr_gid
join = os.path.join
# If these nee... | [
"def",
"install_var",
"(",
"instance",
",",
"clear_target",
",",
"clear_all",
")",
":",
"_check_root",
"(",
")",
"log",
"(",
"\"Checking frontend library and cache directories\"",
",",
"emitter",
"=",
"'MANAGE'",
")",
"uid",
"=",
"pwd",
".",
"getpwnam",
"(",
"\"... | Install required folders in /var | [
"Install",
"required",
"folders",
"in",
"/",
"var"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L130-L172 |
Hackerfleet/hfos | hfos/tool/installer.py | provisions | def provisions(ctx, provision, clear_existing, overwrite, list_provisions):
"""Install default provisioning data"""
install_provisions(ctx, provision, clear_existing, overwrite, list_provisions) | python | def provisions(ctx, provision, clear_existing, overwrite, list_provisions):
"""Install default provisioning data"""
install_provisions(ctx, provision, clear_existing, overwrite, list_provisions) | [
"def",
"provisions",
"(",
"ctx",
",",
"provision",
",",
"clear_existing",
",",
"overwrite",
",",
"list_provisions",
")",
":",
"install_provisions",
"(",
"ctx",
",",
"provision",
",",
"clear_existing",
",",
"overwrite",
",",
"list_provisions",
")"
] | Install default provisioning data | [
"Install",
"default",
"provisioning",
"data"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L186-L189 |
Hackerfleet/hfos | hfos/tool/installer.py | install_provisions | def install_provisions(ctx, provision, clear_provisions=False, overwrite=False, list_provisions=False):
"""Install default provisioning data"""
log("Installing HFOS default provisions")
# from hfos.logger import verbosity, events
# verbosity['console'] = verbosity['global'] = events
from hfos imp... | python | def install_provisions(ctx, provision, clear_provisions=False, overwrite=False, list_provisions=False):
"""Install default provisioning data"""
log("Installing HFOS default provisions")
# from hfos.logger import verbosity, events
# verbosity['console'] = verbosity['global'] = events
from hfos imp... | [
"def",
"install_provisions",
"(",
"ctx",
",",
"provision",
",",
"clear_provisions",
"=",
"False",
",",
"overwrite",
"=",
"False",
",",
"list_provisions",
"=",
"False",
")",
":",
"log",
"(",
"\"Installing HFOS default provisions\"",
")",
"# from hfos.logger import verb... | Install default provisioning data | [
"Install",
"default",
"provisioning",
"data"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L192-L263 |
Hackerfleet/hfos | hfos/tool/installer.py | install_modules | def install_modules(wip):
"""Install the plugin modules"""
def install_module(hfos_module):
"""Install a single module via setuptools"""
try:
setup = Popen(
[
sys.executable,
'setup.py',
'develop'
... | python | def install_modules(wip):
"""Install the plugin modules"""
def install_module(hfos_module):
"""Install a single module via setuptools"""
try:
setup = Popen(
[
sys.executable,
'setup.py',
'develop'
... | [
"def",
"install_modules",
"(",
"wip",
")",
":",
"def",
"install_module",
"(",
"hfos_module",
")",
":",
"\"\"\"Install a single module via setuptools\"\"\"",
"try",
":",
"setup",
"=",
"Popen",
"(",
"[",
"sys",
".",
"executable",
",",
"'setup.py'",
",",
"'develop'",... | Install the plugin modules | [
"Install",
"the",
"plugin",
"modules"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L274-L372 |
Hackerfleet/hfos | hfos/tool/installer.py | service | def service(ctx):
"""Install systemd service configuration"""
install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port']) | python | def service(ctx):
"""Install systemd service configuration"""
install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port']) | [
"def",
"service",
"(",
"ctx",
")",
":",
"install_service",
"(",
"ctx",
".",
"obj",
"[",
"'instance'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'dbhost'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'dbname'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'port'",
"]",
")"... | Install systemd service configuration | [
"Install",
"systemd",
"service",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L377-L380 |
Hackerfleet/hfos | hfos/tool/installer.py | install_service | def install_service(instance, dbhost, dbname, port):
"""Install systemd service configuration"""
_check_root()
log("Installing systemd service")
launcher = os.path.realpath(__file__).replace('manage', 'launcher')
executable = sys.executable + " " + launcher
executable += " --instance " + inst... | python | def install_service(instance, dbhost, dbname, port):
"""Install systemd service configuration"""
_check_root()
log("Installing systemd service")
launcher = os.path.realpath(__file__).replace('manage', 'launcher')
executable = sys.executable + " " + launcher
executable += " --instance " + inst... | [
"def",
"install_service",
"(",
"instance",
",",
"dbhost",
",",
"dbname",
",",
"port",
")",
":",
"_check_root",
"(",
")",
"log",
"(",
"\"Installing systemd service\"",
")",
"launcher",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
".",
"rep... | Install systemd service configuration | [
"Install",
"systemd",
"service",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L383-L422 |
Hackerfleet/hfos | hfos/tool/installer.py | nginx | def nginx(ctx, hostname):
"""Install nginx configuration"""
install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname) | python | def nginx(ctx, hostname):
"""Install nginx configuration"""
install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname) | [
"def",
"nginx",
"(",
"ctx",
",",
"hostname",
")",
":",
"install_nginx",
"(",
"ctx",
".",
"obj",
"[",
"'dbhost'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'dbname'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'port'",
"]",
",",
"hostname",
")"
] | Install nginx configuration | [
"Install",
"nginx",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L430-L433 |
Hackerfleet/hfos | hfos/tool/installer.py | install_nginx | def install_nginx(instance, dbhost, dbname, port, hostname=None):
"""Install nginx configuration"""
_check_root()
log("Installing nginx configuration")
if hostname is None:
try:
configuration = _get_system_configuration(dbhost, dbname)
hostname = configuration.hostname... | python | def install_nginx(instance, dbhost, dbname, port, hostname=None):
"""Install nginx configuration"""
_check_root()
log("Installing nginx configuration")
if hostname is None:
try:
configuration = _get_system_configuration(dbhost, dbname)
hostname = configuration.hostname... | [
"def",
"install_nginx",
"(",
"instance",
",",
"dbhost",
",",
"dbname",
",",
"port",
",",
"hostname",
"=",
"None",
")",
":",
"_check_root",
"(",
")",
"log",
"(",
"\"Installing nginx configuration\"",
")",
"if",
"hostname",
"is",
"None",
":",
"try",
":",
"co... | Install nginx configuration | [
"Install",
"nginx",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L436-L492 |
Hackerfleet/hfos | hfos/tool/installer.py | install_cert | def install_cert(selfsigned):
"""Install a local SSL certificate"""
_check_root()
if selfsigned:
log('Generating self signed (insecure) certificate/key '
'combination')
try:
os.mkdir('/etc/ssl/certs/hfos')
except FileExistsError:
pass
ex... | python | def install_cert(selfsigned):
"""Install a local SSL certificate"""
_check_root()
if selfsigned:
log('Generating self signed (insecure) certificate/key '
'combination')
try:
os.mkdir('/etc/ssl/certs/hfos')
except FileExistsError:
pass
ex... | [
"def",
"install_cert",
"(",
"selfsigned",
")",
":",
"_check_root",
"(",
")",
"if",
"selfsigned",
":",
"log",
"(",
"'Generating self signed (insecure) certificate/key '",
"'combination'",
")",
"try",
":",
"os",
".",
"mkdir",
"(",
"'/etc/ssl/certs/hfos'",
")",
"except... | Install a local SSL certificate | [
"Install",
"a",
"local",
"SSL",
"certificate"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L531-L608 |
Hackerfleet/hfos | hfos/tool/installer.py | frontend | def frontend(ctx, dev, rebuild, no_install, build_type):
"""Build and install frontend"""
install_frontend(instance=ctx.obj['instance'],
forcerebuild=rebuild,
development=dev,
install=not no_install,
build_type=build_type) | python | def frontend(ctx, dev, rebuild, no_install, build_type):
"""Build and install frontend"""
install_frontend(instance=ctx.obj['instance'],
forcerebuild=rebuild,
development=dev,
install=not no_install,
build_type=build_type) | [
"def",
"frontend",
"(",
"ctx",
",",
"dev",
",",
"rebuild",
",",
"no_install",
",",
"build_type",
")",
":",
"install_frontend",
"(",
"instance",
"=",
"ctx",
".",
"obj",
"[",
"'instance'",
"]",
",",
"forcerebuild",
"=",
"rebuild",
",",
"development",
"=",
... | Build and install frontend | [
"Build",
"and",
"install",
"frontend"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L621-L628 |
Hackerfleet/hfos | hfos/tool/installer.py | install_all | def install_all(ctx, clear_all):
"""Default-Install everything installable
\b
This includes
* System user (hfos.hfos)
* Self signed certificate
* Variable data locations (/var/lib/hfos and /var/cache/hfos)
* All the official modules in this repository
* Default module provisioning data
... | python | def install_all(ctx, clear_all):
"""Default-Install everything installable
\b
This includes
* System user (hfos.hfos)
* Self signed certificate
* Variable data locations (/var/lib/hfos and /var/cache/hfos)
* All the official modules in this repository
* Default module provisioning data
... | [
"def",
"install_all",
"(",
"ctx",
",",
"clear_all",
")",
":",
"_check_root",
"(",
")",
"instance",
"=",
"ctx",
".",
"obj",
"[",
"'instance'",
"]",
"dbhost",
"=",
"ctx",
".",
"obj",
"[",
"'dbhost'",
"]",
"dbname",
"=",
"ctx",
".",
"obj",
"[",
"'dbname... | Default-Install everything installable
\b
This includes
* System user (hfos.hfos)
* Self signed certificate
* Variable data locations (/var/lib/hfos and /var/cache/hfos)
* All the official modules in this repository
* Default module provisioning data
* Documentation
* systemd servic... | [
"Default",
"-",
"Install",
"everything",
"installable"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L635-L668 |
Hackerfleet/hfos | hfos/tool/installer.py | uninstall | def uninstall():
"""Uninstall data and resource locations"""
_check_root()
response = _ask("This will delete all data of your HFOS installations! Type"
"YES to continue:", default="N", show_hint=False)
if response == 'YES':
shutil.rmtree('/var/lib/hfos')
shutil.rmtr... | python | def uninstall():
"""Uninstall data and resource locations"""
_check_root()
response = _ask("This will delete all data of your HFOS installations! Type"
"YES to continue:", default="N", show_hint=False)
if response == 'YES':
shutil.rmtree('/var/lib/hfos')
shutil.rmtr... | [
"def",
"uninstall",
"(",
")",
":",
"_check_root",
"(",
")",
"response",
"=",
"_ask",
"(",
"\"This will delete all data of your HFOS installations! Type\"",
"\"YES to continue:\"",
",",
"default",
"=",
"\"N\"",
",",
"show_hint",
"=",
"False",
")",
"if",
"response",
"... | Uninstall data and resource locations | [
"Uninstall",
"data",
"and",
"resource",
"locations"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L672-L681 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.