partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
get_overrides_filename
Get the name of the file containing configuration overrides from the provided environment variable.
ecommerce_worker/configuration/__init__.py
def get_overrides_filename(variable): """ Get the name of the file containing configuration overrides from the provided environment variable. """ filename = os.environ.get(variable) if filename is None: msg = 'Please set the {} environment variable.'.format(variable) raise Envir...
def get_overrides_filename(variable): """ Get the name of the file containing configuration overrides from the provided environment variable. """ filename = os.environ.get(variable) if filename is None: msg = 'Please set the {} environment variable.'.format(variable) raise Envir...
[ "Get", "the", "name", "of", "the", "file", "containing", "configuration", "overrides", "from", "the", "provided", "environment", "variable", "." ]
edx/ecommerce-worker
python
https://github.com/edx/ecommerce-worker/blob/55246961d805b1f64d661a5c0bae0a216589401f/ecommerce_worker/configuration/__init__.py#L9-L20
[ "def", "get_overrides_filename", "(", "variable", ")", ":", "filename", "=", "os", ".", "environ", ".", "get", "(", "variable", ")", "if", "filename", "is", "None", ":", "msg", "=", "'Please set the {} environment variable.'", ".", "format", "(", "variable", "...
55246961d805b1f64d661a5c0bae0a216589401f
test
get_output_files_layout
Parameters ---------- output_category: str inputs: epw, idf table: summary table other: other
oplus/compatibility/outputs.py
def get_output_files_layout(output_category): """ Parameters ---------- output_category: str inputs: epw, idf table: summary table other: other """ # check category if output_category not in ("inputs", "table", "other"): raise RuntimeError(f"unknown {output_c...
def get_output_files_layout(output_category): """ Parameters ---------- output_category: str inputs: epw, idf table: summary table other: other """ # check category if output_category not in ("inputs", "table", "other"): raise RuntimeError(f"unknown {output_c...
[ "Parameters", "----------", "output_category", ":", "str", "inputs", ":", "epw", "idf", "table", ":", "summary", "table", "other", ":", "other" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/compatibility/outputs.py#L60-L77
[ "def", "get_output_files_layout", "(", "output_category", ")", ":", "# check category", "if", "output_category", "not", "in", "(", "\"inputs\"", ",", "\"table\"", ",", "\"other\"", ")", ":", "raise", "RuntimeError", "(", "f\"unknown {output_category}\"", ")", "# get ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
get_value_by_version
Finds the value depending in current eplus version. Parameters ---------- d: dict {(0, 0): value, (x, x): value, ...} for current version (cv), current value is the value of version v such as v <= cv < v+1
oplus/compatibility/util.py
def get_value_by_version(d): """ Finds the value depending in current eplus version. Parameters ---------- d: dict {(0, 0): value, (x, x): value, ...} for current version (cv), current value is the value of version v such as v <= cv < v+1 """ from oplus import CONF # touch...
def get_value_by_version(d): """ Finds the value depending in current eplus version. Parameters ---------- d: dict {(0, 0): value, (x, x): value, ...} for current version (cv), current value is the value of version v such as v <= cv < v+1 """ from oplus import CONF # touch...
[ "Finds", "the", "value", "depending", "in", "current", "eplus", "version", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/compatibility/util.py#L27-L43
[ "def", "get_value_by_version", "(", "d", ")", ":", "from", "oplus", "import", "CONF", "# touchy import", "cv", "=", "CONF", ".", "eplus_version", "[", ":", "2", "]", "for", "v", ",", "value", "in", "sorted", "(", "d", ".", "items", "(", ")", ",", "re...
f095868d1990c1d126e906ada6acbab26348b3d3
test
switch_to_datetime_instants
works inplace
oplus/standard_output/switch_instants.py
def switch_to_datetime_instants(df, start_year, eplus_frequency): """ works inplace """ # timestep -> monthly if eplus_frequency in (TIMESTEP, DAILY, HOURLY, MONTHLY): # prepare year switch if eplus_frequency in (TIMESTEP, HOURLY, DAILY): # print((df[["month", "day"]] - d...
def switch_to_datetime_instants(df, start_year, eplus_frequency): """ works inplace """ # timestep -> monthly if eplus_frequency in (TIMESTEP, DAILY, HOURLY, MONTHLY): # prepare year switch if eplus_frequency in (TIMESTEP, HOURLY, DAILY): # print((df[["month", "day"]] - d...
[ "works", "inplace" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/standard_output/switch_instants.py#L8-L89
[ "def", "switch_to_datetime_instants", "(", "df", ",", "start_year", ",", "eplus_frequency", ")", ":", "# timestep -> monthly", "if", "eplus_frequency", "in", "(", "TIMESTEP", ",", "DAILY", ",", "HOURLY", ",", "MONTHLY", ")", ":", "# prepare year switch", "if", "ep...
f095868d1990c1d126e906ada6acbab26348b3d3
test
_Conf.eplus_version
if _eplus_version is defined => _eplus_version else most recent eplus available version
oplus/configuration.py
def eplus_version(self): """ if _eplus_version is defined => _eplus_version else most recent eplus available version """ # check energy plus is installed if len(self.eplus_available_versions) == 0: raise RuntimeError("Energy plus is not install, can't use oplu...
def eplus_version(self): """ if _eplus_version is defined => _eplus_version else most recent eplus available version """ # check energy plus is installed if len(self.eplus_available_versions) == 0: raise RuntimeError("Energy plus is not install, can't use oplu...
[ "if", "_eplus_version", "is", "defined", "=", ">", "_eplus_version", "else", "most", "recent", "eplus", "available", "version" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/configuration.py#L28-L42
[ "def", "eplus_version", "(", "self", ")", ":", "# check energy plus is installed", "if", "len", "(", "self", ".", "eplus_available_versions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"Energy plus is not install, can't use oplus package.\"", ")", "# see if vers...
f095868d1990c1d126e906ada6acbab26348b3d3
test
_check_and_sanitize_datetime_instants
Parameters ---------- df Returns ------- sanitized df
oplus/weather_data/weather_data.py
def _check_and_sanitize_datetime_instants(df): """ Parameters ---------- df Returns ------- sanitized df """ # leave if not relevant if df is None or len(df) == 0: return df # check datetime index if not isinstance(df.index, pd.DatetimeIndex): raise Valu...
def _check_and_sanitize_datetime_instants(df): """ Parameters ---------- df Returns ------- sanitized df """ # leave if not relevant if df is None or len(df) == 0: return df # check datetime index if not isinstance(df.index, pd.DatetimeIndex): raise Valu...
[ "Parameters", "----------", "df" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/weather_data/weather_data.py#L451-L487
[ "def", "_check_and_sanitize_datetime_instants", "(", "df", ")", ":", "# leave if not relevant", "if", "df", "is", "None", "or", "len", "(", "df", ")", "==", "0", ":", "return", "df", "# check datetime index", "if", "not", "isinstance", "(", "df", ".", "index",...
f095868d1990c1d126e906ada6acbab26348b3d3
test
WeatherData.get_bounds
Returns ------- (start, end) Datetime instants of beginning and end of data. If no data, will be: (None, None).
oplus/weather_data/weather_data.py
def get_bounds(self): """ Returns ------- (start, end) Datetime instants of beginning and end of data. If no data, will be: (None, None). """ start, end = None, None if len(self._weather_series) == 0: return start, end for i in (0, -1...
def get_bounds(self): """ Returns ------- (start, end) Datetime instants of beginning and end of data. If no data, will be: (None, None). """ start, end = None, None if len(self._weather_series) == 0: return start, end for i in (0, -1...
[ "Returns", "-------", "(", "start", "end", ")" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/weather_data/weather_data.py#L314-L340
[ "def", "get_bounds", "(", "self", ")", ":", "start", ",", "end", "=", "None", ",", "None", "if", "len", "(", "self", ".", "_weather_series", ")", "==", "0", ":", "return", "start", ",", "end", "for", "i", "in", "(", "0", ",", "-", "1", ")", ":"...
f095868d1990c1d126e906ada6acbab26348b3d3
test
WeatherData.from_epw
Parameters ---------- buffer_or_path: buffer or path containing epw format. Returns ------- WeatherData instance.
oplus/weather_data/weather_data.py
def from_epw(cls, buffer_or_path): """ Parameters ---------- buffer_or_path: buffer or path containing epw format. Returns ------- WeatherData instance. """ from .epw_parse import parse_epw _, buffer = to_buffer(buffer_or_path) wit...
def from_epw(cls, buffer_or_path): """ Parameters ---------- buffer_or_path: buffer or path containing epw format. Returns ------- WeatherData instance. """ from .epw_parse import parse_epw _, buffer = to_buffer(buffer_or_path) wit...
[ "Parameters", "----------", "buffer_or_path", ":", "buffer", "or", "path", "containing", "epw", "format", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/weather_data/weather_data.py#L356-L369
[ "def", "from_epw", "(", "cls", ",", "buffer_or_path", ")", ":", "from", ".", "epw_parse", "import", "parse_epw", "_", ",", "buffer", "=", "to_buffer", "(", "buffer_or_path", ")", "with", "buffer", "as", "f", ":", "return", "parse_epw", "(", "f", ")" ]
f095868d1990c1d126e906ada6acbab26348b3d3
test
WeatherData.to_epw
Parameters ---------- buffer_or_path: buffer or path, default None Buffer or path to write into. If None, will return a string containing epw info. Returns ------- None or a string if buffer_or_path is None.
oplus/weather_data/weather_data.py
def to_epw(self, buffer_or_path=None): """ Parameters ---------- buffer_or_path: buffer or path, default None Buffer or path to write into. If None, will return a string containing epw info. Returns ------- None or a string if buffer_or_path is None. ...
def to_epw(self, buffer_or_path=None): """ Parameters ---------- buffer_or_path: buffer or path, default None Buffer or path to write into. If None, will return a string containing epw info. Returns ------- None or a string if buffer_or_path is None. ...
[ "Parameters", "----------", "buffer_or_path", ":", "buffer", "or", "path", "default", "None", "Buffer", "or", "path", "to", "write", "into", ".", "If", "None", "will", "return", "a", "string", "containing", "epw", "info", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/weather_data/weather_data.py#L372-L391
[ "def", "to_epw", "(", "self", ",", "buffer_or_path", "=", "None", ")", ":", "# copy and change hours convention [0, 23] -> [1, 24]", "df", "=", "self", ".", "_weather_series", ".", "copy", "(", ")", "df", "[", "\"hour\"", "]", "+=", "1", "epw_content", "=", "s...
f095868d1990c1d126e906ada6acbab26348b3d3
test
parse_idf
Records are created from string. They are not attached to idf yet. in idf: header comment, chapter comments, records in record: head comment, field comments, tail comment
oplus/epm/parse_idf.py
def parse_idf(file_like): """ Records are created from string. They are not attached to idf yet. in idf: header comment, chapter comments, records in record: head comment, field comments, tail comment """ tables_data = {} head_comment = "" record_data = None make_new_record = Tru...
def parse_idf(file_like): """ Records are created from string. They are not attached to idf yet. in idf: header comment, chapter comments, records in record: head comment, field comments, tail comment """ tables_data = {} head_comment = "" record_data = None make_new_record = Tru...
[ "Records", "are", "created", "from", "string", ".", "They", "are", "not", "attached", "to", "idf", "yet", ".", "in", "idf", ":", "header", "comment", "chapter", "comments", "records", "in", "record", ":", "head", "comment", "field", "comments", "tail", "co...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/parse_idf.py#L5-L102
[ "def", "parse_idf", "(", "file_like", ")", ":", "tables_data", "=", "{", "}", "head_comment", "=", "\"\"", "record_data", "=", "None", "make_new_record", "=", "True", "copyright_list", "=", "get_multi_line_copyright_message", "(", ")", ".", "split", "(", "\"\\n\...
f095868d1990c1d126e906ada6acbab26348b3d3
test
run_eplus
Parameters ---------- epm_or_idf_path: weather_data_or_epw_path simulation_dir_path stdout: default sys.stdout stderr: default sys.stderr beat_freq: if not none, stdout will be used at least every beat_freq (in seconds)
oplus/simulation.py
def run_eplus(epm_or_idf_path, weather_data_or_epw_path, simulation_dir_path, stdout=None, stderr=None, beat_freq=None): """ Parameters ---------- epm_or_idf_path: weather_data_or_epw_path simulation_dir_path stdout: default sys.stdout stderr: default sys.stderr beat_freq: if not non...
def run_eplus(epm_or_idf_path, weather_data_or_epw_path, simulation_dir_path, stdout=None, stderr=None, beat_freq=None): """ Parameters ---------- epm_or_idf_path: weather_data_or_epw_path simulation_dir_path stdout: default sys.stdout stderr: default sys.stderr beat_freq: if not non...
[ "Parameters", "----------", "epm_or_idf_path", ":", "weather_data_or_epw_path", "simulation_dir_path", "stdout", ":", "default", "sys", ".", "stdout", "stderr", ":", "default", "sys", ".", "stderr", "beat_freq", ":", "if", "not", "none", "stdout", "will", "be", "u...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/simulation.py#L313-L398
[ "def", "run_eplus", "(", "epm_or_idf_path", ",", "weather_data_or_epw_path", ",", "simulation_dir_path", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ",", "beat_freq", "=", "None", ")", ":", "# work with absolute paths", "simulation_dir_path", "=", "os", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Simulation.simulate
Parameters ---------- epm_or_path weather_data_or_path base_dir_path: simulation dir path simulation_name: str, default None if provided, simulation will be done in {base_dir_path}/{simulation_name} else, simulation will be done in {base_dir_path} ...
oplus/simulation.py
def simulate( cls, epm_or_path, weather_data_or_path, base_dir_path, simulation_name=None, stdout=None, stderr=None, beat_freq=None ): """ Parameters ---------- epm_or_path weather...
def simulate( cls, epm_or_path, weather_data_or_path, base_dir_path, simulation_name=None, stdout=None, stderr=None, beat_freq=None ): """ Parameters ---------- epm_or_path weather...
[ "Parameters", "----------", "epm_or_path", "weather_data_or_path", "base_dir_path", ":", "simulation", "dir", "path", "simulation_name", ":", "str", "default", "None", "if", "provided", "simulation", "will", "be", "done", "in", "{", "base_dir_path", "}", "/", "{", ...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/simulation.py#L112-L168
[ "def", "simulate", "(", "cls", ",", "epm_or_path", ",", "weather_data_or_path", ",", "base_dir_path", ",", "simulation_name", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ",", "beat_freq", "=", "None", ")", ":", "# manage simulation dir...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Simulation._file_refs
Defined here so that we can use the class variables, in order to subclass in oplusplus
oplus/simulation.py
def _file_refs(self): """ Defined here so that we can use the class variables, in order to subclass in oplusplus """ if self._prepared_file_refs is None: self._prepared_file_refs = { FILE_REFS.idf: FileInfo( constructor=lambda path: self._e...
def _file_refs(self): """ Defined here so that we can use the class variables, in order to subclass in oplusplus """ if self._prepared_file_refs is None: self._prepared_file_refs = { FILE_REFS.idf: FileInfo( constructor=lambda path: self._e...
[ "Defined", "here", "so", "that", "we", "can", "use", "the", "class", "variables", "in", "order", "to", "subclass", "in", "oplusplus" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/simulation.py#L203-L250
[ "def", "_file_refs", "(", "self", ")", ":", "if", "self", ".", "_prepared_file_refs", "is", "None", ":", "self", ".", "_prepared_file_refs", "=", "{", "FILE_REFS", ".", "idf", ":", "FileInfo", "(", "constructor", "=", "lambda", "path", ":", "self", ".", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Simulation.exists
Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Returns ------- Boolean
oplus/simulation.py
def exists(self, file_ref): """ Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Returns ...
def exists(self, file_ref): """ Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Returns ...
[ "Parameters", "----------", "file_ref", ":", "str", "reference", "of", "file", ".", "Available", "references", ":", "idf", "epw", "eio", "eso", "mtr", "mtd", "mdd", "err", "summary_table", "See", "EnergyPlus", "documentation", "for", "more", "information", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/simulation.py#L275-L290
[ "def", "exists", "(", "self", ",", "file_ref", ")", ":", "if", "file_ref", "not", "in", "FILE_REFS", ":", "raise", "ValueError", "(", "\"Unknown file_ref: '%s'. Available: '%s'.\"", "%", "(", "file_ref", ",", "list", "(", "sorted", "(", "FILE_REFS", ".", "_fie...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Simulation.get_file_path
Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Returns ------- Instance of required outpu...
oplus/simulation.py
def get_file_path(self, file_ref): """ Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Ret...
def get_file_path(self, file_ref): """ Parameters ---------- file_ref: str reference of file. Available references: 'idf', 'epw', 'eio', 'eso', 'mtr', 'mtd', 'mdd', 'err', 'summary_table' See EnergyPlus documentation for more information. Ret...
[ "Parameters", "----------", "file_ref", ":", "str", "reference", "of", "file", ".", "Available", "references", ":", "idf", "epw", "eio", "eso", "mtr", "mtd", "mdd", "err", "summary_table", "See", "EnergyPlus", "documentation", "for", "more", "information", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/simulation.py#L292-L307
[ "def", "get_file_path", "(", "self", ",", "file_ref", ")", ":", "if", "not", "self", ".", "exists", "(", "file_ref", ")", ":", "raise", "FileNotFoundError", "(", "\"File '%s' not found in simulation '%s'.\"", "%", "(", "file_ref", ",", "self", ".", "_path", "(...
f095868d1990c1d126e906ada6acbab26348b3d3
test
default_external_files_dir_name
Parameters ---------- model_name: with or without extension
oplus/epm/epm.py
def default_external_files_dir_name(model_name): """ Parameters ---------- model_name: with or without extension """ name, ext = os.path.splitext(model_name) return name + CONF.external_files_suffix
def default_external_files_dir_name(model_name): """ Parameters ---------- model_name: with or without extension """ name, ext = os.path.splitext(model_name) return name + CONF.external_files_suffix
[ "Parameters", "----------", "model_name", ":", "with", "or", "without", "extension" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L27-L34
[ "def", "default_external_files_dir_name", "(", "model_name", ")", ":", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "model_name", ")", "return", "name", "+", "CONF", ".", "external_files_suffix" ]
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm._dev_populate_from_json_data
!! Must only be called once, when empty !!
oplus/epm/epm.py
def _dev_populate_from_json_data(self, json_data): """ !! Must only be called once, when empty !! """ # workflow # -------- # (methods belonging to create/update/delete framework: # epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.de...
def _dev_populate_from_json_data(self, json_data): """ !! Must only be called once, when empty !! """ # workflow # -------- # (methods belonging to create/update/delete framework: # epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.de...
[ "!!", "Must", "only", "be", "called", "once", "when", "empty", "!!" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L100-L143
[ "def", "_dev_populate_from_json_data", "(", "self", ",", "json_data", ")", ":", "# workflow", "# --------", "# (methods belonging to create/update/delete framework:", "# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete)", "# 1. add inert", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.get_external_files
An external file manages file paths.
oplus/epm/epm.py
def get_external_files(self): """ An external file manages file paths. """ external_files = [] for table in self._tables.values(): for r in table: external_files.extend([ef for ef in r.get_external_files()]) return external_files
def get_external_files(self): """ An external file manages file paths. """ external_files = [] for table in self._tables.values(): for r in table: external_files.extend([ef for ef in r.get_external_files()]) return external_files
[ "An", "external", "file", "manages", "file", "paths", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L187-L195
[ "def", "get_external_files", "(", "self", ")", ":", "external_files", "=", "[", "]", "for", "table", "in", "self", ".", "_tables", ".", "values", "(", ")", ":", "for", "r", "in", "table", ":", "external_files", ".", "extend", "(", "[", "ef", "for", "...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.set_defaults
All fields of Epm with a default value and that are null will be set to their default value.
oplus/epm/epm.py
def set_defaults(self): """ All fields of Epm with a default value and that are null will be set to their default value. """ for table in self._tables.values(): for r in table: r.set_defaults()
def set_defaults(self): """ All fields of Epm with a default value and that are null will be set to their default value. """ for table in self._tables.values(): for r in table: r.set_defaults()
[ "All", "fields", "of", "Epm", "with", "a", "default", "value", "and", "that", "are", "null", "will", "be", "set", "to", "their", "default", "value", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L201-L207
[ "def", "set_defaults", "(", "self", ")", ":", "for", "table", "in", "self", ".", "_tables", ".", "values", "(", ")", ":", "for", "r", "in", "table", ":", "r", ".", "set_defaults", "(", ")" ]
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.from_json_data
Parameters ---------- json_data: dict Dictionary of serialized data (text, floats, ints, ...). For more information on data structure, create an Epm and use to_json_data or to_json. check_required: boolean, default True If True, will raise an exception if a re...
oplus/epm/epm.py
def from_json_data(cls, json_data, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- json_data: dict Dictionary of serialized data (text, floats, ints, ...). For more information on data structure, create an Epm and use to_json_data or to...
def from_json_data(cls, json_data, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- json_data: dict Dictionary of serialized data (text, floats, ints, ...). For more information on data structure, create an Epm and use to_json_data or to...
[ "Parameters", "----------", "json_data", ":", "dict", "Dictionary", "of", "serialized", "data", "(", "text", "floats", "ints", "...", ")", ".", "For", "more", "information", "on", "data", "structure", "create", "an", "Epm", "and", "use", "to_json_data", "or", ...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L219-L240
[ "def", "from_json_data", "(", "cls", ",", "json_data", ",", "check_required", "=", "True", ",", "idd_or_buffer_or_path", "=", "None", ")", ":", "epm", "=", "cls", "(", "idd_or_buffer_or_path", "=", "idd_or_buffer_or_path", ",", "check_required", "=", "check_requir...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.from_idf
Parameters ---------- buffer_or_path: idf buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not perform any checks. idd_or_buffer_or_path: (expert) to load using a custom idd Returns ...
oplus/epm/epm.py
def from_idf(cls, buffer_or_path, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- buffer_or_path: idf buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not pe...
def from_idf(cls, buffer_or_path, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- buffer_or_path: idf buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not pe...
[ "Parameters", "----------", "buffer_or_path", ":", "idf", "buffer", "or", "path", "check_required", ":", "boolean", "default", "True", "If", "True", "will", "raise", "an", "exception", "if", "a", "required", "field", "is", "missing", ".", "If", "False", "not",...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L243-L262
[ "def", "from_idf", "(", "cls", ",", "buffer_or_path", ",", "check_required", "=", "True", ",", "idd_or_buffer_or_path", "=", "None", ")", ":", "# todo: add geometry only (or equivalent)", "return", "cls", ".", "_create_from_buffer_or_path", "(", "parse_idf", ",", "buf...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.from_json
Parameters ---------- buffer_or_path: json buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not perform any checks. idd_or_buffer_or_path: (expert) to load using a custom idd Returns ...
oplus/epm/epm.py
def from_json(cls, buffer_or_path, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- buffer_or_path: json buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not ...
def from_json(cls, buffer_or_path, check_required=True, idd_or_buffer_or_path=None): """ Parameters ---------- buffer_or_path: json buffer or path check_required: boolean, default True If True, will raise an exception if a required field is missing. If False, not not ...
[ "Parameters", "----------", "buffer_or_path", ":", "json", "buffer", "or", "path", "check_required", ":", "boolean", "default", "True", "If", "True", "will", "raise", "an", "exception", "if", "a", "required", "field", "is", "missing", ".", "If", "False", "not"...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L265-L283
[ "def", "from_json", "(", "cls", ",", "buffer_or_path", ",", "check_required", "=", "True", ",", "idd_or_buffer_or_path", "=", "None", ")", ":", "return", "cls", ".", "_create_from_buffer_or_path", "(", "json", ".", "load", ",", "buffer_or_path", ",", "idd_or_buf...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.to_json_data
Returns ------- A dictionary of serialized data.
oplus/epm/epm.py
def to_json_data(self): """ Returns ------- A dictionary of serialized data. """ # create data d = collections.OrderedDict((t.get_ref(), t.to_json_data()) for t in self._tables.values()) d["_comment"] = self._comment d.move_to_end("_comment", last=...
def to_json_data(self): """ Returns ------- A dictionary of serialized data. """ # create data d = collections.OrderedDict((t.get_ref(), t.to_json_data()) for t in self._tables.values()) d["_comment"] = self._comment d.move_to_end("_comment", last=...
[ "Returns", "-------", "A", "dictionary", "of", "serialized", "data", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L286-L297
[ "def", "to_json_data", "(", "self", ")", ":", "# create data", "d", "=", "collections", ".", "OrderedDict", "(", "(", "t", ".", "get_ref", "(", ")", ",", "t", ".", "to_json_data", "(", ")", ")", "for", "t", "in", "self", ".", "_tables", ".", "values"...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.to_json
Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. indent: int, default 2 Defines the indentation of the json Returns ------- None, or a json string (if buffer_or_path is No...
oplus/epm/epm.py
def to_json(self, buffer_or_path=None, indent=2): """ Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. indent: int, default 2 Defines the indentation of the json Returns ...
def to_json(self, buffer_or_path=None, indent=2): """ Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. indent: int, default 2 Defines the indentation of the json Returns ...
[ "Parameters", "----------", "buffer_or_path", ":", "buffer", "or", "path", "default", "None", "output", "to", "write", "into", ".", "If", "None", "will", "return", "a", "json", "string", ".", "indent", ":", "int", "default", "2", "Defines", "the", "indentati...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L299-L317
[ "def", "to_json", "(", "self", ",", "buffer_or_path", "=", "None", ",", "indent", "=", "2", ")", ":", "# return json", "return", "json_data_to_json", "(", "self", ".", "to_json_data", "(", ")", ",", "buffer_or_path", "=", "buffer_or_path", ",", "indent", "="...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Epm.to_idf
Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. dump_external_files: boolean, default True if True, external files will be dumped in external files directory Returns ------- ...
oplus/epm/epm.py
def to_idf(self, buffer_or_path=None, dump_external_files=True): """ Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. dump_external_files: boolean, default True if True, external f...
def to_idf(self, buffer_or_path=None, dump_external_files=True): """ Parameters ---------- buffer_or_path: buffer or path, default None output to write into. If None, will return a json string. dump_external_files: boolean, default True if True, external f...
[ "Parameters", "----------", "buffer_or_path", ":", "buffer", "or", "path", "default", "None", "output", "to", "write", "into", ".", "If", "None", "will", "return", "a", "json", "string", ".", "dump_external_files", ":", "boolean", "default", "True", "if", "Tru...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L319-L363
[ "def", "to_idf", "(", "self", ",", "buffer_or_path", "=", "None", ",", "dump_external_files", "=", "True", ")", ":", "# prepare comment", "comment", "=", "get_multi_line_copyright_message", "(", ")", "if", "self", ".", "_comment", "!=", "\"\"", ":", "comment", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Queryset.select
Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of queryset), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). If None, records are not filtered. Returns ...
oplus/epm/queryset.py
def select(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of queryset), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). ...
def select(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of queryset), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). ...
[ "Parameters", "----------", "filter_by", ":", "callable", "default", "None", "Callable", "must", "take", "one", "argument", "(", "a", "record", "of", "queryset", ")", "and", "return", "True", "to", "keep", "record", "or", "False", "to", "skip", "it", ".", ...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/queryset.py#L94-L108
[ "def", "select", "(", "self", ",", "filter_by", "=", "None", ")", ":", "iterator", "=", "self", ".", "_records", "if", "filter_by", "is", "None", "else", "filter", "(", "filter_by", ",", "self", ".", "_records", ")", "return", "Queryset", "(", "self", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Queryset.one
Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None, records are not filtered. Returns ...
oplus/epm/queryset.py
def one(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None,...
def one(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None,...
[ "Parameters", "----------", "filter_by", ":", "callable", "default", "None", "Callable", "must", "take", "one", "argument", "(", "a", "record", "of", "table", ")", "and", "return", "True", "to", "keep", "record", "or", "False", "to", "skip", "it", ".", "Ex...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/queryset.py#L110-L138
[ "def", "one", "(", "self", ",", "filter_by", "=", "None", ")", ":", "# filter if needed", "qs", "=", "self", "if", "filter_by", "is", "None", "else", "self", ".", "select", "(", "filter_by", "=", "filter_by", ")", "# check one and only one", "if", "len", "...
f095868d1990c1d126e906ada6acbab26348b3d3
test
get_simulated_epw_path
Returns ------- None if epw can be anywhere
oplus/compatibility/epw.py
def get_simulated_epw_path(): """ Returns ------- None if epw can be anywhere """ from oplus import CONF # touchy imports if OS_NAME == "windows": return os.path.join(CONF.eplus_base_dir_path, "WeatherData", "%s.epw" % CONF.default_model_name)
def get_simulated_epw_path(): """ Returns ------- None if epw can be anywhere """ from oplus import CONF # touchy imports if OS_NAME == "windows": return os.path.join(CONF.eplus_base_dir_path, "WeatherData", "%s.epw" % CONF.default_model_name)
[ "Returns", "-------", "None", "if", "epw", "can", "be", "anywhere" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/compatibility/epw.py#L6-L15
[ "def", "get_simulated_epw_path", "(", ")", ":", "from", "oplus", "import", "CONF", "# touchy imports", "if", "OS_NAME", "==", "\"windows\"", ":", "return", "os", ".", "path", ".", "join", "(", "CONF", ".", "eplus_base_dir_path", ",", "\"WeatherData\"", ",", "\...
f095868d1990c1d126e906ada6acbab26348b3d3
test
TableDescriptor.prepare_extensible
This function finishes initialization, must be called once all field descriptors and tag have been filled.
oplus/epm/table_descriptor.py
def prepare_extensible(self): """ This function finishes initialization, must be called once all field descriptors and tag have been filled. """ # see if extensible and store cycle len for k in self._tags: if "extensible" in k: cycle_len = int(k.split(...
def prepare_extensible(self): """ This function finishes initialization, must be called once all field descriptors and tag have been filled. """ # see if extensible and store cycle len for k in self._tags: if "extensible" in k: cycle_len = int(k.split(...
[ "This", "function", "finishes", "initialization", "must", "be", "called", "once", "all", "field", "descriptors", "and", "tag", "have", "been", "filled", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table_descriptor.py#L49-L91
[ "def", "prepare_extensible", "(", "self", ")", ":", "# see if extensible and store cycle len", "for", "k", "in", "self", ".", "_tags", ":", "if", "\"extensible\"", "in", "k", ":", "cycle_len", "=", "int", "(", "k", ".", "split", "(", "\":\"", ")", "[", "1"...
f095868d1990c1d126e906ada6acbab26348b3d3
test
TableDescriptor.get_field_reduced_index
reduced index: modulo of extensible has been applied
oplus/epm/table_descriptor.py
def get_field_reduced_index(self, index): """ reduced index: modulo of extensible has been applied """ # return index if not extensible if self.extensible_info is None: return index # manage extensible cycle_start, cycle_len, _ = self.extensib...
def get_field_reduced_index(self, index): """ reduced index: modulo of extensible has been applied """ # return index if not extensible if self.extensible_info is None: return index # manage extensible cycle_start, cycle_len, _ = self.extensib...
[ "reduced", "index", ":", "modulo", "of", "extensible", "has", "been", "applied" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table_descriptor.py#L125-L141
[ "def", "get_field_reduced_index", "(", "self", ",", "index", ")", ":", "# return index if not extensible", "if", "self", ".", "extensible_info", "is", "None", ":", "return", "index", "# manage extensible", "cycle_start", ",", "cycle_len", ",", "_", "=", "self", "....
f095868d1990c1d126e906ada6acbab26348b3d3
test
TableDescriptor.get_extended_name
manages extensible names
oplus/epm/table_descriptor.py
def get_extended_name(self, index): """ manages extensible names """ field_descriptor = self.get_field_descriptor(index) if self.extensible_info is None: return field_descriptor.name cycle_start, cycle_len, _ = self.extensible_info cycle_num = (index -...
def get_extended_name(self, index): """ manages extensible names """ field_descriptor = self.get_field_descriptor(index) if self.extensible_info is None: return field_descriptor.name cycle_start, cycle_len, _ = self.extensible_info cycle_num = (index -...
[ "manages", "extensible", "names" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table_descriptor.py#L146-L155
[ "def", "get_extended_name", "(", "self", ",", "index", ")", ":", "field_descriptor", "=", "self", ".", "get_field_descriptor", "(", "index", ")", "if", "self", ".", "extensible_info", "is", "None", ":", "return", "field_descriptor", ".", "name", "cycle_start", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
FieldDescriptor.deserialize
index is used for extensible fields error messages (if given)
oplus/epm/field_descriptor.py
def deserialize(self, value, index): """ index is used for extensible fields error messages (if given) """ # -- serialize if not raw type # transform to string if external file if isinstance(value, ExternalFile): value = value.pointer # transform to s...
def deserialize(self, value, index): """ index is used for extensible fields error messages (if given) """ # -- serialize if not raw type # transform to string if external file if isinstance(value, ExternalFile): value = value.pointer # transform to s...
[ "index", "is", "used", "for", "extensible", "fields", "error", "messages", "(", "if", "given", ")" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/field_descriptor.py#L57-L159
[ "def", "deserialize", "(", "self", ",", "value", ",", "index", ")", ":", "# -- serialize if not raw type", "# transform to string if external file", "if", "isinstance", "(", "value", ",", "ExternalFile", ")", ":", "value", "=", "value", ".", "pointer", "# transform ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
FieldDescriptor.detailed_type
Uses EPlus double approach of type ('type' tag, and/or 'key', 'object-list', 'external-list', 'reference' tags) to determine detailed type. Returns ------- "integer", "real", "alpha", "choice", "reference", "object-list", "external-list", "node"
oplus/epm/field_descriptor.py
def detailed_type(self): """ Uses EPlus double approach of type ('type' tag, and/or 'key', 'object-list', 'external-list', 'reference' tags) to determine detailed type. Returns ------- "integer", "real", "alpha", "choice", "reference", "object-list", "external-li...
def detailed_type(self): """ Uses EPlus double approach of type ('type' tag, and/or 'key', 'object-list', 'external-list', 'reference' tags) to determine detailed type. Returns ------- "integer", "real", "alpha", "choice", "reference", "object-list", "external-li...
[ "Uses", "EPlus", "double", "approach", "of", "type", "(", "type", "tag", "and", "/", "or", "key", "object", "-", "list", "external", "-", "list", "reference", "tags", ")", "to", "determine", "detailed", "type", ".", "Returns", "-------", "integer", "real",...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/field_descriptor.py#L176-L202
[ "def", "detailed_type", "(", "self", ")", ":", "if", "self", ".", "_detailed_type", "is", "None", ":", "if", "(", "\"reference\"", "in", "self", ".", "tags", ")", "or", "(", "\"reference-class-name\"", "in", "self", ".", "tags", ")", ":", "self", ".", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
ExternalFilesManager.short_refs
we calculate on the fly to avoid managing registrations and un-registrations Returns ------- {ref: short_ref, ...
oplus/epm/external_files_manager.py
def short_refs(self): """ we calculate on the fly to avoid managing registrations and un-registrations Returns ------- {ref: short_ref, ... """ naive_short_refs_d = dict() # naive_short_ref: {refs, ...} for ef in self._external_files: if ef.n...
def short_refs(self): """ we calculate on the fly to avoid managing registrations and un-registrations Returns ------- {ref: short_ref, ... """ naive_short_refs_d = dict() # naive_short_ref: {refs, ...} for ef in self._external_files: if ef.n...
[ "we", "calculate", "on", "the", "fly", "to", "avoid", "managing", "registrations", "and", "un", "-", "registrations" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/external_files_manager.py#L19-L42
[ "def", "short_refs", "(", "self", ")", ":", "naive_short_refs_d", "=", "dict", "(", ")", "# naive_short_ref: {refs, ...}", "for", "ef", "in", "self", ".", "_external_files", ":", "if", "ef", ".", "naive_short_ref", "not", "in", "naive_short_refs_d", ":", "naive_...
f095868d1990c1d126e906ada6acbab26348b3d3
test
EioTable.get_value
Returns first occurrence of value of filter column matching filter criterion.
oplus/eio.py
def get_value(self, column_name_or_i, filter_column_name_or_i, filter_criterion): """ Returns first occurrence of value of filter column matching filter criterion. """ # find column indexes column_i = self._get_column_index(column_name_or_i) filter_column_i = self._get_co...
def get_value(self, column_name_or_i, filter_column_name_or_i, filter_criterion): """ Returns first occurrence of value of filter column matching filter criterion. """ # find column indexes column_i = self._get_column_index(column_name_or_i) filter_column_i = self._get_co...
[ "Returns", "first", "occurrence", "of", "value", "of", "filter", "column", "matching", "filter", "criterion", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/eio.py#L109-L129
[ "def", "get_value", "(", "self", ",", "column_name_or_i", ",", "filter_column_name_or_i", ",", "filter_criterion", ")", ":", "# find column indexes", "column_i", "=", "self", ".", "_get_column_index", "(", "column_name_or_i", ")", "filter_column_i", "=", "self", ".", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record._update_value_inert
is only called by _update_inert
oplus/epm/record.py
def _update_value_inert(self, index, value): """ is only called by _update_inert """ # get field descriptor field_descriptor = self._table._dev_descriptor.get_field_descriptor(index) # prepare value value = field_descriptor.deserialize(value, index) # un...
def _update_value_inert(self, index, value): """ is only called by _update_inert """ # get field descriptor field_descriptor = self._table._dev_descriptor.get_field_descriptor(index) # prepare value value = field_descriptor.deserialize(value, index) # un...
[ "is", "only", "called", "by", "_update_inert" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L85-L130
[ "def", "_update_value_inert", "(", "self", ",", "index", ",", "value", ")", ":", "# get field descriptor", "field_descriptor", "=", "self", ".", "_table", ".", "_dev_descriptor", ".", "get_field_descriptor", "(", "index", ")", "# prepare value", "value", "=", "fie...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.get_serialized_value
Parameters ---------- ref_or_index external_files_mode: str, default 'path' 'path', 'pointer' model_file_path: str, default None if external files are asked in a relative fashion, relative path will be calculated relatively to model_file_path if given,...
oplus/epm/record.py
def get_serialized_value(self, ref_or_index, model_name=None): """ Parameters ---------- ref_or_index external_files_mode: str, default 'path' 'path', 'pointer' model_file_path: str, default None if external files are asked in a relative fashion, r...
def get_serialized_value(self, ref_or_index, model_name=None): """ Parameters ---------- ref_or_index external_files_mode: str, default 'path' 'path', 'pointer' model_file_path: str, default None if external files are asked in a relative fashion, r...
[ "Parameters", "----------", "ref_or_index", "external_files_mode", ":", "str", "default", "path", "path", "pointer", "model_file_path", ":", "str", "default", "None", "if", "external", "files", "are", "asked", "in", "a", "relative", "fashion", "relative", "path", ...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L355-L385
[ "def", "get_serialized_value", "(", "self", ",", "ref_or_index", ",", "model_name", "=", "None", ")", ":", "index", "=", "(", "self", ".", "_table", ".", "_dev_descriptor", ".", "get_field_index", "(", "ref_or_index", ")", "if", "isinstance", "(", "ref_or_inde...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.get_external_files
Returns ------- List of ExternalFiles instances contained by record.
oplus/epm/record.py
def get_external_files(self): """ Returns ------- List of ExternalFiles instances contained by record. """ return [v for v in self._data.values() if isinstance(v, ExternalFile)]
def get_external_files(self): """ Returns ------- List of ExternalFiles instances contained by record. """ return [v for v in self._data.values() if isinstance(v, ExternalFile)]
[ "Returns", "-------", "List", "of", "ExternalFiles", "instances", "contained", "by", "record", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L403-L409
[ "def", "get_external_files", "(", "self", ")", ":", "return", "[", "v", "for", "v", "in", "self", ".", "_data", ".", "values", "(", ")", "if", "isinstance", "(", "v", ",", "ExternalFile", ")", "]" ]
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.update
Updates simultaneously all given fields. Parameters ---------- data: dictionary containing field lowercase names or index as keys, and field values as values (dict syntax) or_data: keyword arguments containing field names as keys (kwargs syntax)
oplus/epm/record.py
def update(self, data=None, **or_data): """ Updates simultaneously all given fields. Parameters ---------- data: dictionary containing field lowercase names or index as keys, and field values as values (dict syntax) or_data: keyword arguments containing field names as ke...
def update(self, data=None, **or_data): """ Updates simultaneously all given fields. Parameters ---------- data: dictionary containing field lowercase names or index as keys, and field values as values (dict syntax) or_data: keyword arguments containing field names as ke...
[ "Updates", "simultaneously", "all", "given", "fields", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L412-L438
[ "def", "update", "(", "self", ",", "data", "=", "None", ",", "*", "*", "or_data", ")", ":", "# workflow", "# --------", "# (methods belonging to create/update/delete framework:", "# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.copy
Parameters ---------- new_name: str, default None record's new name (if table has a name). If None although record has a name, a random uuid will be given. Returns ------- Copied record.
oplus/epm/record.py
def copy(self, new_name=None): """ Parameters ---------- new_name: str, default None record's new name (if table has a name). If None although record has a name, a random uuid will be given. Returns ------- Copied record. """ # todo: c...
def copy(self, new_name=None): """ Parameters ---------- new_name: str, default None record's new name (if table has a name). If None although record has a name, a random uuid will be given. Returns ------- Copied record. """ # todo: c...
[ "Parameters", "----------", "new_name", ":", "str", "default", "None", "record", "s", "new", "name", "(", "if", "table", "has", "a", "name", ")", ".", "If", "None", "although", "record", "has", "a", "name", "a", "random", "uuid", "will", "be", "given", ...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L440-L459
[ "def", "copy", "(", "self", ",", "new_name", "=", "None", ")", ":", "# todo: check this really works, !! must not use same link, hook, external_file, ... for different records !!", "# auto pk tables can just be copied", "if", "self", ".", "_table", ".", "_dev_auto_pk", ":", "re...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.set_defaults
sets all empty fields for which a default value is defined to default value
oplus/epm/record.py
def set_defaults(self): """ sets all empty fields for which a default value is defined to default value """ defaults = {} for i in range(len(self)): if i in self._data: continue default = self.get_field_descriptor(i).tags.get("default", [No...
def set_defaults(self): """ sets all empty fields for which a default value is defined to default value """ defaults = {} for i in range(len(self)): if i in self._data: continue default = self.get_field_descriptor(i).tags.get("default", [No...
[ "sets", "all", "empty", "fields", "for", "which", "a", "default", "value", "is", "defined", "to", "default", "value" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L461-L473
[ "def", "set_defaults", "(", "self", ")", ":", "defaults", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "if", "i", "in", "self", ".", "_data", ":", "continue", "default", "=", "self", ".", "get_field_descriptor", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.add_fields
This method only works for extensible fields. It allows to add values without precising their fields' names or indexes. Parameters ---------- args: field values
oplus/epm/record.py
def add_fields(self, *args): """ This method only works for extensible fields. It allows to add values without precising their fields' names or indexes. Parameters ---------- args: field values """ if not self.is_extensible(): raise TypeError(...
def add_fields(self, *args): """ This method only works for extensible fields. It allows to add values without precising their fields' names or indexes. Parameters ---------- args: field values """ if not self.is_extensible(): raise TypeError(...
[ "This", "method", "only", "works", "for", "extensible", "fields", ".", "It", "allows", "to", "add", "values", "without", "precising", "their", "fields", "names", "or", "indexes", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L476-L493
[ "def", "add_fields", "(", "self", ",", "*", "args", ")", ":", "if", "not", "self", ".", "is_extensible", "(", ")", ":", "raise", "TypeError", "(", "\"Can't use add_fields on a non extensible record.\"", ")", "# prepare update data", "self_len", "=", "len", "(", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.pop
This method only works for extensible fields. It allows to remove a value and shift all other values to fill the gap. Parameters ---------- index: int, default None index of field to remove. Returns ------- serialize value of popped field
oplus/epm/record.py
def pop(self, index=None): """ This method only works for extensible fields. It allows to remove a value and shift all other values to fill the gap. Parameters ---------- index: int, default None index of field to remove. Returns ------- ...
def pop(self, index=None): """ This method only works for extensible fields. It allows to remove a value and shift all other values to fill the gap. Parameters ---------- index: int, default None index of field to remove. Returns ------- ...
[ "This", "method", "only", "works", "for", "extensible", "fields", ".", "It", "allows", "to", "remove", "a", "value", "and", "shift", "all", "other", "values", "to", "fill", "the", "gap", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L495-L524
[ "def", "pop", "(", "self", ",", "index", "=", "None", ")", ":", "# prepare index (will check for extensible)", "index", "=", "self", ".", "_prepare_pop_insert_index", "(", "index", "=", "index", ")", "# get extensible info", "cycle_start", ",", "cycle_len", ",", "...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.insert
This method only works for extensible fields. It allows to insert a value, and shifts all other following values. Parameters ---------- index: position of insertion value: value to insert
oplus/epm/record.py
def insert(self, index, value): """ This method only works for extensible fields. It allows to insert a value, and shifts all other following values. Parameters ---------- index: position of insertion value: value to insert """ # prepare index (wi...
def insert(self, index, value): """ This method only works for extensible fields. It allows to insert a value, and shifts all other following values. Parameters ---------- index: position of insertion value: value to insert """ # prepare index (wi...
[ "This", "method", "only", "works", "for", "extensible", "fields", ".", "It", "allows", "to", "insert", "a", "value", "and", "shifts", "all", "other", "following", "values", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L526-L546
[ "def", "insert", "(", "self", ",", "index", ",", "value", ")", ":", "# prepare index (will check for extensible)", "index", "=", "self", ".", "_prepare_pop_insert_index", "(", "index", "=", "index", ")", "# remove extensible fields", "fields", "=", "self", ".", "c...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.clear_extensible_fields
Returns ------- list of cleared fields (serialized)
oplus/epm/record.py
def clear_extensible_fields(self): """ Returns ------- list of cleared fields (serialized) """ if not self.is_extensible(): raise TypeError("Can't use add_fields on a non extensible record.") cycle_start, cycle_len, patterns = self.get_extensible_info(...
def clear_extensible_fields(self): """ Returns ------- list of cleared fields (serialized) """ if not self.is_extensible(): raise TypeError("Can't use add_fields on a non extensible record.") cycle_start, cycle_len, patterns = self.get_extensible_info(...
[ "Returns", "-------", "list", "of", "cleared", "fields", "(", "serialized", ")" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L548-L557
[ "def", "clear_extensible_fields", "(", "self", ")", ":", "if", "not", "self", ".", "is_extensible", "(", ")", ":", "raise", "TypeError", "(", "\"Can't use add_fields on a non extensible record.\"", ")", "cycle_start", ",", "cycle_len", ",", "patterns", "=", "self", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.delete
Deletes record, and removes it from database.
oplus/epm/record.py
def delete(self): """ Deletes record, and removes it from database. """ # workflow # -------- # (methods belonging to create/update/delete framework: # epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete) # ...
def delete(self): """ Deletes record, and removes it from database. """ # workflow # -------- # (methods belonging to create/update/delete framework: # epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete) # ...
[ "Deletes", "record", "and", "removes", "it", "from", "database", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L560-L585
[ "def", "delete", "(", "self", ")", ":", "# workflow", "# --------", "# (methods belonging to create/update/delete framework:", "# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete)", "# 1. unregister: links, hooks and external files", "# 3. re...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.get_field_descriptor
Parameters ---------- ref_or_index: str or int field lowercase name, or field position Returns ------- Field descriptor (info contained in Idd)
oplus/epm/record.py
def get_field_descriptor(self, ref_or_index): """ Parameters ---------- ref_or_index: str or int field lowercase name, or field position Returns ------- Field descriptor (info contained in Idd) """ if isinstance(ref_or_index, int): ...
def get_field_descriptor(self, ref_or_index): """ Parameters ---------- ref_or_index: str or int field lowercase name, or field position Returns ------- Field descriptor (info contained in Idd) """ if isinstance(ref_or_index, int): ...
[ "Parameters", "----------", "ref_or_index", ":", "str", "or", "int", "field", "lowercase", "name", "or", "field", "position" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L588-L603
[ "def", "get_field_descriptor", "(", "self", ",", "ref_or_index", ")", ":", "if", "isinstance", "(", "ref_or_index", ",", "int", ")", ":", "index", "=", "ref_or_index", "else", ":", "index", "=", "self", ".", "_table", ".", "_dev_descriptor", ".", "get_field_...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.to_json_data
Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- A dictionary of serialized data.
oplus/epm/record.py
def to_json_data(self, model_name=None): """ Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- A dictionary of serialized data. """ return collections.Ordere...
def to_json_data(self, model_name=None): """ Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- A dictionary of serialized data. """ return collections.Ordere...
[ "Parameters", "----------", "model_name", ":", "str", "default", "None", "if", "given", "will", "be", "used", "as", "external", "file", "directory", "base", "name" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L623-L634
[ "def", "to_json_data", "(", "self", ",", "model_name", "=", "None", ")", ":", "return", "collections", ".", "OrderedDict", "(", "[", "(", "k", ",", "self", ".", "get_serialized_value", "(", "k", ",", "model_name", "=", "model_name", ")", ")", "for", "k",...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Record.to_idf
Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- idf string
oplus/epm/record.py
def to_idf(self, model_name=None): """ Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- idf string """ json_data = self.to_json_data(model_name=model_name...
def to_idf(self, model_name=None): """ Parameters ---------- model_name: str, default None if given, will be used as external file directory base name Returns ------- idf string """ json_data = self.to_json_data(model_name=model_name...
[ "Parameters", "----------", "model_name", ":", "str", "default", "None", "if", "given", "will", "be", "used", "as", "external", "file", "directory", "base", "name" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/record.py#L636-L676
[ "def", "to_idf", "(", "self", ",", "model_name", "=", "None", ")", ":", "json_data", "=", "self", ".", "to_json_data", "(", "model_name", "=", "model_name", ")", "# record descriptor ref", "s", "=", "f\"{self._table._dev_descriptor.table_name},\\n\"", "# fields", "#...
f095868d1990c1d126e906ada6acbab26348b3d3
test
check
Tested under EPlus 8.1.0 on Windows (Geoffroy).
check/check_many_simulations.py
def check(): """ Tested under EPlus 8.1.0 on Windows (Geoffroy). """ # !! CAN BE VERY LONG epw_path = os.path.join(CONF.eplus_base_dir_path, "WeatherData", "USA_VA_Sterling-Washington.Dulles.Intl.AP.724030_TMY3.epw") idf_dir_path = os.path.join(CONF.eplus_base_dir_pat...
def check(): """ Tested under EPlus 8.1.0 on Windows (Geoffroy). """ # !! CAN BE VERY LONG epw_path = os.path.join(CONF.eplus_base_dir_path, "WeatherData", "USA_VA_Sterling-Washington.Dulles.Intl.AP.724030_TMY3.epw") idf_dir_path = os.path.join(CONF.eplus_base_dir_pat...
[ "Tested", "under", "EPlus", "8", ".", "1", ".", "0", "on", "Windows", "(", "Geoffroy", ")", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/check/check_many_simulations.py#L12-L34
[ "def", "check", "(", ")", ":", "# !! CAN BE VERY LONG", "epw_path", "=", "os", ".", "path", ".", "join", "(", "CONF", ".", "eplus_base_dir_path", ",", "\"WeatherData\"", ",", "\"USA_VA_Sterling-Washington.Dulles.Intl.AP.724030_TMY3.epw\"", ")", "idf_dir_path", "=", "o...
f095868d1990c1d126e906ada6acbab26348b3d3
test
StandardOutput.get_data
Parameters ---------- environment_title_or_num frequency: 'str', default None 'timestep', 'hourly', 'daily', 'monthly', 'annual', 'run_period' If None, will look for the smallest frequency of environment.
oplus/standard_output/standard_output.py
def get_data(self, environment_title_or_num=-1, frequency=None): """ Parameters ---------- environment_title_or_num frequency: 'str', default None 'timestep', 'hourly', 'daily', 'monthly', 'annual', 'run_period' If None, will look for the smallest frequenc...
def get_data(self, environment_title_or_num=-1, frequency=None): """ Parameters ---------- environment_title_or_num frequency: 'str', default None 'timestep', 'hourly', 'daily', 'monthly', 'annual', 'run_period' If None, will look for the smallest frequenc...
[ "Parameters", "----------", "environment_title_or_num", "frequency", ":", "str", "default", "None", "timestep", "hourly", "daily", "monthly", "annual", "run_period", "If", "None", "will", "look", "for", "the", "smallest", "frequency", "of", "environment", "." ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/standard_output/standard_output.py#L53-L85
[ "def", "get_data", "(", "self", ",", "environment_title_or_num", "=", "-", "1", ",", "frequency", "=", "None", ")", ":", "# manage environment num", "if", "isinstance", "(", "environment_title_or_num", ",", "int", ")", ":", "environment_title", "=", "tuple", "("...
f095868d1990c1d126e906ada6acbab26348b3d3
test
get_documented_add
this hack is used to document add function a methods __doc__ attribute is read-only (or must use metaclasses, what I certainly don't want to do...) we therefore create a function (who's __doc__ attribute is read/write), and will bind it to Table in __init__
oplus/epm/table.py
def get_documented_add(self, record_descriptors): """ this hack is used to document add function a methods __doc__ attribute is read-only (or must use metaclasses, what I certainly don't want to do...) we therefore create a function (who's __doc__ attribute is read/write), and will bind it to Table in _...
def get_documented_add(self, record_descriptors): """ this hack is used to document add function a methods __doc__ attribute is read-only (or must use metaclasses, what I certainly don't want to do...) we therefore create a function (who's __doc__ attribute is read/write), and will bind it to Table in _...
[ "this", "hack", "is", "used", "to", "document", "add", "function", "a", "methods", "__doc__", "attribute", "is", "read", "-", "only", "(", "or", "must", "use", "metaclasses", "what", "I", "certainly", "don", "t", "want", "to", "do", "...", ")", "we", "...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table.py#L6-L53
[ "def", "get_documented_add", "(", "self", ",", "record_descriptors", ")", ":", "def", "add", "(", "data", "=", "None", ",", "*", "*", "or_data", ")", ":", "\"\"\"\n Parameters\n ----------\n data: dictionary containing field lowercase names or index as ke...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Table._dev_add_inert
inert: hooks and links are not activated
oplus/epm/table.py
def _dev_add_inert(self, records_data): """ inert: hooks and links are not activated """ added_records = [] for r_data in records_data: # create record record = Record( self, data=r_data ) # store ...
def _dev_add_inert(self, records_data): """ inert: hooks and links are not activated """ added_records = [] for r_data in records_data: # create record record = Record( self, data=r_data ) # store ...
[ "inert", ":", "hooks", "and", "links", "are", "not", "activated" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table.py#L90-L109
[ "def", "_dev_add_inert", "(", "self", ",", "records_data", ")", ":", "added_records", "=", "[", "]", "for", "r_data", "in", "records_data", ":", "# create record", "record", "=", "Record", "(", "self", ",", "data", "=", "r_data", ")", "# store", "# we don't ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Table.select
Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). If None, records are not filtered. Returns ...
oplus/epm/table.py
def select(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). If...
def select(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .select(lambda x: x.name == "my_name"). If...
[ "Parameters", "----------", "filter_by", ":", "callable", "default", "None", "Callable", "must", "take", "one", "argument", "(", "a", "record", "of", "table", ")", "and", "return", "True", "to", "keep", "record", "or", "False", "to", "skip", "it", ".", "Ex...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table.py#L175-L189
[ "def", "select", "(", "self", ",", "filter_by", "=", "None", ")", ":", "records", "=", "self", ".", "_records", ".", "values", "(", ")", "if", "filter_by", "is", "None", "else", "filter", "(", "filter_by", ",", "self", ".", "_records", ".", "values", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Table.one
Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None, records are not filtered. Returns ...
oplus/epm/table.py
def one(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None,...
def one(self, filter_by=None): """ Parameters ---------- filter_by: callable, default None Callable must take one argument (a record of table), and return True to keep record, or False to skip it. Example : .one(lambda x: x.name == "my_name"). If None,...
[ "Parameters", "----------", "filter_by", ":", "callable", "default", "None", "Callable", "must", "take", "one", "argument", "(", "a", "record", "of", "table", ")", "and", "return", "True", "to", "keep", "record", "or", "False", "to", "skip", "it", ".", "Ex...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table.py#L191-L209
[ "def", "one", "(", "self", ",", "filter_by", "=", "None", ")", ":", "return", "Queryset", "(", "self", ",", "records", "=", "self", ".", "_records", ".", "values", "(", ")", ")", ".", "one", "(", "filter_by", "=", "filter_by", ")" ]
f095868d1990c1d126e906ada6acbab26348b3d3
test
Table.batch_add
Parameters ---------- records_data: list of dictionaries containing records data. Keys of dictionary may be field names and/or field indexes Returns ------- Queryset instance of added records
oplus/epm/table.py
def batch_add(self, records_data): """ Parameters ---------- records_data: list of dictionaries containing records data. Keys of dictionary may be field names and/or field indexes Returns ------- Queryset instance of added records """ ...
def batch_add(self, records_data): """ Parameters ---------- records_data: list of dictionaries containing records data. Keys of dictionary may be field names and/or field indexes Returns ------- Queryset instance of added records """ ...
[ "Parameters", "----------", "records_data", ":", "list", "of", "dictionaries", "containing", "records", "data", ".", "Keys", "of", "dictionary", "may", "be", "field", "names", "and", "/", "or", "field", "indexes" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/table.py#L216-L250
[ "def", "batch_add", "(", "self", ",", "records_data", ")", ":", "# workflow", "# --------", "# (methods belonging to create/update/delete framework:", "# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete)", "# 1. add inert", "# * data ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
RelationsManager.register_record_hook
target record must have been set
oplus/epm/relations_manager.py
def register_record_hook(self, hook): """ target record must have been set """ for key in hook.keys: if key in self._record_hooks: field_descriptor = hook.target_record.get_field_descriptor(hook.target_index) raise FieldValidationError( ...
def register_record_hook(self, hook): """ target record must have been set """ for key in hook.keys: if key in self._record_hooks: field_descriptor = hook.target_record.get_field_descriptor(hook.target_index) raise FieldValidationError( ...
[ "target", "record", "must", "have", "been", "set" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/relations_manager.py#L47-L58
[ "def", "register_record_hook", "(", "self", ",", "hook", ")", ":", "for", "key", "in", "hook", ".", "keys", ":", "if", "key", "in", "self", ".", "_record_hooks", ":", "field_descriptor", "=", "hook", ".", "target_record", ".", "get_field_descriptor", "(", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
RelationsManager.register_link
source record and index must have been set
oplus/epm/relations_manager.py
def register_link(self, link): """ source record and index must have been set """ keys = tuple((ref, link.initial_hook_value) for ref in link.hook_references) # look for a record hook for k in keys: if k in self._record_hooks: # set link targe...
def register_link(self, link): """ source record and index must have been set """ keys = tuple((ref, link.initial_hook_value) for ref in link.hook_references) # look for a record hook for k in keys: if k in self._record_hooks: # set link targe...
[ "source", "record", "and", "index", "must", "have", "been", "set" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/relations_manager.py#L65-L99
[ "def", "register_link", "(", "self", ",", "link", ")", ":", "keys", "=", "tuple", "(", "(", "ref", ",", "link", ".", "initial_hook_value", ")", "for", "ref", "in", "link", ".", "hook_references", ")", "# look for a record hook", "for", "k", "in", "keys", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
run_subprocess
Parameters ---------- command: command cwd: current working directory stdout: output info stream (must have 'write' method) stderr: output error stream (must have 'write' method) shell: see subprocess.Popen beat_freq: if not none, stdout will be used at least every beat_freq (in seconds)
oplus/util.py
def run_subprocess(command, cwd=None, stdout=None, stderr=None, shell=False, beat_freq=None): """ Parameters ---------- command: command cwd: current working directory stdout: output info stream (must have 'write' method) stderr: output error stream (must have 'write' method) shell: see ...
def run_subprocess(command, cwd=None, stdout=None, stderr=None, shell=False, beat_freq=None): """ Parameters ---------- command: command cwd: current working directory stdout: output info stream (must have 'write' method) stderr: output error stream (must have 'write' method) shell: see ...
[ "Parameters", "----------", "command", ":", "command", "cwd", ":", "current", "working", "directory", "stdout", ":", "output", "info", "stream", "(", "must", "have", "write", "method", ")", "stderr", ":", "output", "error", "stream", "(", "must", "have", "wr...
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/util.py#L81-L116
[ "def", "run_subprocess", "(", "command", ",", "cwd", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ",", "shell", "=", "False", ",", "beat_freq", "=", "None", ")", ":", "sys", ".", "encoding", "=", "CONF", ".", "encoding", "# pr...
f095868d1990c1d126e906ada6acbab26348b3d3
test
get_string_buffer
path_or_content: path or content_str or content_bts or string_io or bytes_io Returns ------- string_buffer, path path will be None if input was not a path
oplus/util.py
def get_string_buffer(path_or_content, expected_extension): """ path_or_content: path or content_str or content_bts or string_io or bytes_io Returns ------- string_buffer, path path will be None if input was not a path """ buffer, path = None, None # path or content string if...
def get_string_buffer(path_or_content, expected_extension): """ path_or_content: path or content_str or content_bts or string_io or bytes_io Returns ------- string_buffer, path path will be None if input was not a path """ buffer, path = None, None # path or content string if...
[ "path_or_content", ":", "path", "or", "content_str", "or", "content_bts", "or", "string_io", "or", "bytes_io" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/util.py#L119-L153
[ "def", "get_string_buffer", "(", "path_or_content", ",", "expected_extension", ")", ":", "buffer", ",", "path", "=", "None", ",", "None", "# path or content string", "if", "isinstance", "(", "path_or_content", ",", "str", ")", ":", "if", "path_or_content", "[", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
Err.get_data
Parameters ---------- simulation_step: if not given, returns a raw report error_category: if only one argument is specified, swaps dataframe report
oplus/err.py
def get_data(self, simulation_step=None, error_category=None): """ Parameters ---------- simulation_step: if not given, returns a raw report error_category: if only one argument is specified, swaps dataframe report """ if simulation_step is None and error_category...
def get_data(self, simulation_step=None, error_category=None): """ Parameters ---------- simulation_step: if not given, returns a raw report error_category: if only one argument is specified, swaps dataframe report """ if simulation_step is None and error_category...
[ "Parameters", "----------", "simulation_step", ":", "if", "not", "given", "returns", "a", "raw", "report", "error_category", ":", "if", "only", "one", "argument", "is", "specified", "swaps", "dataframe", "report" ]
openergy/oplus
python
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/err.py#L121-L153
[ "def", "get_data", "(", "self", ",", "simulation_step", "=", "None", ",", "error_category", "=", "None", ")", ":", "if", "simulation_step", "is", "None", "and", "error_category", "is", "None", ":", "return", "self", ".", "_df", ".", "dropna", "(", "axis", ...
f095868d1990c1d126e906ada6acbab26348b3d3
test
IntentContainer._create_regex
Create regex and return. If error occurs returns None.
padaos.py
def _create_regex(self, line, intent_name): """ Create regex and return. If error occurs returns None. """ try: return re.compile(self._create_intent_pattern(line, intent_name), re.IGNORECASE) except sre_constants.error as e: LOG.warning('Fai...
def _create_regex(self, line, intent_name): """ Create regex and return. If error occurs returns None. """ try: return re.compile(self._create_intent_pattern(line, intent_name), re.IGNORECASE) except sre_constants.error as e: LOG.warning('Fai...
[ "Create", "regex", "and", "return", ".", "If", "error", "occurs", "returns", "None", "." ]
MycroftAI/padaos
python
https://github.com/MycroftAI/padaos/blob/c7fb3d72fefbe552963c5a5a0f606e1f2fde2968/padaos.py#L104-L112
[ "def", "_create_regex", "(", "self", ",", "line", ",", "intent_name", ")", ":", "try", ":", "return", "re", ".", "compile", "(", "self", ".", "_create_intent_pattern", "(", "line", ",", "intent_name", ")", ",", "re", ".", "IGNORECASE", ")", "except", "sr...
c7fb3d72fefbe552963c5a5a0f606e1f2fde2968
test
Constants.str
Convert status (id) to its string name.
pyca/db.py
def str(cls, value): '''Convert status (id) to its string name.''' for k, v in cls.__dict__.items(): if k[0] in string.ascii_uppercase and v == value: return k.lower().replace('_', ' ')
def str(cls, value): '''Convert status (id) to its string name.''' for k, v in cls.__dict__.items(): if k[0] in string.ascii_uppercase and v == value: return k.lower().replace('_', ' ')
[ "Convert", "status", "(", "id", ")", "to", "its", "string", "name", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/db.py#L43-L47
[ "def", "str", "(", "cls", ",", "value", ")", ":", "for", "k", ",", "v", "in", "cls", ".", "__dict__", ".", "items", "(", ")", ":", "if", "k", "[", "0", "]", "in", "string", ".", "ascii_uppercase", "and", "v", "==", "value", ":", "return", "k", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
BaseEvent.remaining_duration
Returns the remaining duration for a recording.
pyca/db.py
def remaining_duration(self, time): '''Returns the remaining duration for a recording. ''' return max(0, self.end - max(self.start, time))
def remaining_duration(self, time): '''Returns the remaining duration for a recording. ''' return max(0, self.end - max(self.start, time))
[ "Returns", "the", "remaining", "duration", "for", "a", "recording", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/db.py#L115-L118
[ "def", "remaining_duration", "(", "self", ",", "time", ")", ":", "return", "max", "(", "0", ",", "self", ".", "end", "-", "max", "(", "self", ".", "start", ",", "time", ")", ")" ]
c89b168d4780d157e1b3f7676628c1b131956a88
test
BaseEvent.serialize
Serialize this object as dictionary usable for conversion to JSON. :return: Dictionary representing this object.
pyca/db.py
def serialize(self): '''Serialize this object as dictionary usable for conversion to JSON. :return: Dictionary representing this object. ''' return { 'type': 'event', 'id': self.uid, 'attributes': { 'start': self.start, ...
def serialize(self): '''Serialize this object as dictionary usable for conversion to JSON. :return: Dictionary representing this object. ''' return { 'type': 'event', 'id': self.uid, 'attributes': { 'start': self.start, ...
[ "Serialize", "this", "object", "as", "dictionary", "usable", "for", "conversion", "to", "JSON", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/db.py#L144-L160
[ "def", "serialize", "(", "self", ")", ":", "return", "{", "'type'", ":", "'event'", ",", "'id'", ":", "self", ".", "uid", ",", "'attributes'", ":", "{", "'start'", ":", "self", ".", "start", ",", "'end'", ":", "self", ".", "end", ",", "'uid'", ":",...
c89b168d4780d157e1b3f7676628c1b131956a88
test
http_request
Make an HTTP request to a given URL with optional parameters.
pyca/utils.py
def http_request(url, post_data=None): '''Make an HTTP request to a given URL with optional parameters. ''' logger.debug('Requesting URL: %s' % url) buf = bio() curl = pycurl.Curl() curl.setopt(curl.URL, url.encode('ascii', 'ignore')) # Disable HTTPS verification methods if insecure is set ...
def http_request(url, post_data=None): '''Make an HTTP request to a given URL with optional parameters. ''' logger.debug('Requesting URL: %s' % url) buf = bio() curl = pycurl.Curl() curl.setopt(curl.URL, url.encode('ascii', 'ignore')) # Disable HTTPS verification methods if insecure is set ...
[ "Make", "an", "HTTP", "request", "to", "a", "given", "URL", "with", "optional", "parameters", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L33-L66
[ "def", "http_request", "(", "url", ",", "post_data", "=", "None", ")", ":", "logger", ".", "debug", "(", "'Requesting URL: %s'", "%", "url", ")", "buf", "=", "bio", "(", ")", "curl", "=", "pycurl", ".", "Curl", "(", ")", "curl", ".", "setopt", "(", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
get_service
Get available service endpoints for a given service type from the Opencast ServiceRegistry.
pyca/utils.py
def get_service(service_type): '''Get available service endpoints for a given service type from the Opencast ServiceRegistry. ''' endpoint = '/services/available.json?serviceType=' + str(service_type) url = '%s%s' % (config()['server']['url'], endpoint) response = http_request(url).decode('utf-8...
def get_service(service_type): '''Get available service endpoints for a given service type from the Opencast ServiceRegistry. ''' endpoint = '/services/available.json?serviceType=' + str(service_type) url = '%s%s' % (config()['server']['url'], endpoint) response = http_request(url).decode('utf-8...
[ "Get", "available", "service", "endpoints", "for", "a", "given", "service", "type", "from", "the", "Opencast", "ServiceRegistry", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L69-L82
[ "def", "get_service", "(", "service_type", ")", ":", "endpoint", "=", "'/services/available.json?serviceType='", "+", "str", "(", "service_type", ")", "url", "=", "'%s%s'", "%", "(", "config", "(", ")", "[", "'server'", "]", "[", "'url'", "]", ",", "endpoint...
c89b168d4780d157e1b3f7676628c1b131956a88
test
unix_ts
Convert datetime into a unix timestamp. This is the equivalent to Python 3's int(datetime.timestamp()). :param dt: datetime to convert
pyca/utils.py
def unix_ts(dtval): '''Convert datetime into a unix timestamp. This is the equivalent to Python 3's int(datetime.timestamp()). :param dt: datetime to convert ''' epoch = datetime(1970, 1, 1, 0, 0, tzinfo=tzutc()) delta = (dtval - epoch) return delta.days * 24 * 3600 + delta.seconds
def unix_ts(dtval): '''Convert datetime into a unix timestamp. This is the equivalent to Python 3's int(datetime.timestamp()). :param dt: datetime to convert ''' epoch = datetime(1970, 1, 1, 0, 0, tzinfo=tzutc()) delta = (dtval - epoch) return delta.days * 24 * 3600 + delta.seconds
[ "Convert", "datetime", "into", "a", "unix", "timestamp", ".", "This", "is", "the", "equivalent", "to", "Python", "3", "s", "int", "(", "datetime", ".", "timestamp", "()", ")", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L85-L93
[ "def", "unix_ts", "(", "dtval", ")", ":", "epoch", "=", "datetime", "(", "1970", ",", "1", ",", "1", ",", "0", ",", "0", ",", "tzinfo", "=", "tzutc", "(", ")", ")", "delta", "=", "(", "dtval", "-", "epoch", ")", "return", "delta", ".", "days", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
try_mkdir
Try to create a directory. Pass without error if it already exists.
pyca/utils.py
def try_mkdir(directory): '''Try to create a directory. Pass without error if it already exists. ''' try: os.mkdir(directory) except OSError as err: if err.errno != errno.EEXIST: raise err
def try_mkdir(directory): '''Try to create a directory. Pass without error if it already exists. ''' try: os.mkdir(directory) except OSError as err: if err.errno != errno.EEXIST: raise err
[ "Try", "to", "create", "a", "directory", ".", "Pass", "without", "error", "if", "it", "already", "exists", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L102-L109
[ "def", "try_mkdir", "(", "directory", ")", ":", "try", ":", "os", ".", "mkdir", "(", "directory", ")", "except", "OSError", "as", "err", ":", "if", "err", ".", "errno", "!=", "errno", ".", "EEXIST", ":", "raise", "err" ]
c89b168d4780d157e1b3f7676628c1b131956a88
test
configure_service
Get the location of a given service from Opencast and add it to the current configuration.
pyca/utils.py
def configure_service(service): '''Get the location of a given service from Opencast and add it to the current configuration. ''' while not config().get('service-' + service) and not terminate(): try: config()['service-' + service] = \ get_service('org.opencastproject...
def configure_service(service): '''Get the location of a given service from Opencast and add it to the current configuration. ''' while not config().get('service-' + service) and not terminate(): try: config()['service-' + service] = \ get_service('org.opencastproject...
[ "Get", "the", "location", "of", "a", "given", "service", "from", "Opencast", "and", "add", "it", "to", "the", "current", "configuration", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L112-L123
[ "def", "configure_service", "(", "service", ")", ":", "while", "not", "config", "(", ")", ".", "get", "(", "'service-'", "+", "service", ")", "and", "not", "terminate", "(", ")", ":", "try", ":", "config", "(", ")", "[", "'service-'", "+", "service", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
register_ca
Register this capture agent at the Matterhorn admin server so that it shows up in the admin interface. :param address: Address of the capture agent web ui :param status: Current status of the capture agent
pyca/utils.py
def register_ca(status='idle'): '''Register this capture agent at the Matterhorn admin server so that it shows up in the admin interface. :param address: Address of the capture agent web ui :param status: Current status of the capture agent ''' # If this is a backup CA we don't tell the Matterh...
def register_ca(status='idle'): '''Register this capture agent at the Matterhorn admin server so that it shows up in the admin interface. :param address: Address of the capture agent web ui :param status: Current status of the capture agent ''' # If this is a backup CA we don't tell the Matterh...
[ "Register", "this", "capture", "agent", "at", "the", "Matterhorn", "admin", "server", "so", "that", "it", "shows", "up", "in", "the", "admin", "interface", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L131-L150
[ "def", "register_ca", "(", "status", "=", "'idle'", ")", ":", "# If this is a backup CA we don't tell the Matterhorn core that we are", "# here. We will just run silently in the background:", "if", "config", "(", ")", "[", "'agent'", "]", "[", "'backup_mode'", "]", ":", "r...
c89b168d4780d157e1b3f7676628c1b131956a88
test
recording_state
Send the state of the current recording to the Matterhorn core. :param recording_id: ID of the current recording :param status: Status of the recording
pyca/utils.py
def recording_state(recording_id, status): '''Send the state of the current recording to the Matterhorn core. :param recording_id: ID of the current recording :param status: Status of the recording ''' # If this is a backup CA we do not update the recording state since the # actual CA does that...
def recording_state(recording_id, status): '''Send the state of the current recording to the Matterhorn core. :param recording_id: ID of the current recording :param status: Status of the recording ''' # If this is a backup CA we do not update the recording state since the # actual CA does that...
[ "Send", "the", "state", "of", "the", "current", "recording", "to", "the", "Matterhorn", "core", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L153-L171
[ "def", "recording_state", "(", "recording_id", ",", "status", ")", ":", "# If this is a backup CA we do not update the recording state since the", "# actual CA does that and we want to interfere. We will just run silently", "# in the background:", "if", "config", "(", ")", "[", "'ag...
c89b168d4780d157e1b3f7676628c1b131956a88
test
update_event_status
Update the status of a particular event in the database.
pyca/utils.py
def update_event_status(event, status): '''Update the status of a particular event in the database. ''' dbs = db.get_session() dbs.query(db.RecordedEvent).filter(db.RecordedEvent.start == event.start)\ .update({'status': status}) event.status = status dbs.commit()
def update_event_status(event, status): '''Update the status of a particular event in the database. ''' dbs = db.get_session() dbs.query(db.RecordedEvent).filter(db.RecordedEvent.start == event.start)\ .update({'status': status}) event.status = status dbs.commit()
[ "Update", "the", "status", "of", "a", "particular", "event", "in", "the", "database", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L174-L181
[ "def", "update_event_status", "(", "event", ",", "status", ")", ":", "dbs", "=", "db", ".", "get_session", "(", ")", "dbs", ".", "query", "(", "db", ".", "RecordedEvent", ")", ".", "filter", "(", "db", ".", "RecordedEvent", ".", "start", "==", "event",...
c89b168d4780d157e1b3f7676628c1b131956a88
test
set_service_status
Update the status of a particular service in the database.
pyca/utils.py
def set_service_status(service, status): '''Update the status of a particular service in the database. ''' srv = db.ServiceStates() srv.type = service srv.status = status dbs = db.get_session() dbs.merge(srv) dbs.commit() dbs.close()
def set_service_status(service, status): '''Update the status of a particular service in the database. ''' srv = db.ServiceStates() srv.type = service srv.status = status dbs = db.get_session() dbs.merge(srv) dbs.commit() dbs.close()
[ "Update", "the", "status", "of", "a", "particular", "service", "in", "the", "database", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L184-L194
[ "def", "set_service_status", "(", "service", ",", "status", ")", ":", "srv", "=", "db", ".", "ServiceStates", "(", ")", "srv", ".", "type", "=", "service", "srv", ".", "status", "=", "status", "dbs", "=", "db", ".", "get_session", "(", ")", "dbs", "....
c89b168d4780d157e1b3f7676628c1b131956a88
test
get_service_status
Update the status of a particular service in the database.
pyca/utils.py
def get_service_status(service): '''Update the status of a particular service in the database. ''' dbs = db.get_session() srvs = dbs.query(db.ServiceStates).filter(db.ServiceStates.type == service) if srvs.count(): return srvs[0].status return db.ServiceStatus.STOPPED
def get_service_status(service): '''Update the status of a particular service in the database. ''' dbs = db.get_session() srvs = dbs.query(db.ServiceStates).filter(db.ServiceStates.type == service) if srvs.count(): return srvs[0].status return db.ServiceStatus.STOPPED
[ "Update", "the", "status", "of", "a", "particular", "service", "in", "the", "database", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L205-L214
[ "def", "get_service_status", "(", "service", ")", ":", "dbs", "=", "db", ".", "get_session", "(", ")", "srvs", "=", "dbs", ".", "query", "(", "db", ".", "ServiceStates", ")", ".", "filter", "(", "db", ".", "ServiceStates", ".", "type", "==", "service",...
c89b168d4780d157e1b3f7676628c1b131956a88
test
update_agent_state
Update the current agent state in opencast.
pyca/utils.py
def update_agent_state(): '''Update the current agent state in opencast. ''' configure_service('capture.admin') status = 'idle' # Determine reported agent state with priority list if get_service_status(db.Service.SCHEDULE) == db.ServiceStatus.STOPPED: status = 'offline' elif get_ser...
def update_agent_state(): '''Update the current agent state in opencast. ''' configure_service('capture.admin') status = 'idle' # Determine reported agent state with priority list if get_service_status(db.Service.SCHEDULE) == db.ServiceStatus.STOPPED: status = 'offline' elif get_ser...
[ "Update", "the", "current", "agent", "state", "in", "opencast", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/utils.py#L217-L231
[ "def", "update_agent_state", "(", ")", ":", "configure_service", "(", "'capture.admin'", ")", "status", "=", "'idle'", "# Determine reported agent state with priority list", "if", "get_service_status", "(", "db", ".", "Service", ".", "SCHEDULE", ")", "==", "db", ".", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
configuration_file
Find the best match for the configuration file.
pyca/config.py
def configuration_file(cfgfile): '''Find the best match for the configuration file. ''' if cfgfile is not None: return cfgfile # If no file is explicitely specified, probe for the configuration file # location. cfg = './etc/pyca.conf' if not os.path.isfile(cfg): return '/etc/...
def configuration_file(cfgfile): '''Find the best match for the configuration file. ''' if cfgfile is not None: return cfgfile # If no file is explicitely specified, probe for the configuration file # location. cfg = './etc/pyca.conf' if not os.path.isfile(cfg): return '/etc/...
[ "Find", "the", "best", "match", "for", "the", "configuration", "file", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/config.py#L62-L72
[ "def", "configuration_file", "(", "cfgfile", ")", ":", "if", "cfgfile", "is", "not", "None", ":", "return", "cfgfile", "# If no file is explicitely specified, probe for the configuration file", "# location.", "cfg", "=", "'./etc/pyca.conf'", "if", "not", "os", ".", "pat...
c89b168d4780d157e1b3f7676628c1b131956a88
test
update_configuration
Update configuration from file. :param cfgfile: Configuration file to load.
pyca/config.py
def update_configuration(cfgfile=None): '''Update configuration from file. :param cfgfile: Configuration file to load. ''' configobj.DEFAULT_INTERPOLATION = 'template' cfgfile = configuration_file(cfgfile) cfg = configobj.ConfigObj(cfgfile, configspec=cfgspec, encoding='utf-8') validator = ...
def update_configuration(cfgfile=None): '''Update configuration from file. :param cfgfile: Configuration file to load. ''' configobj.DEFAULT_INTERPOLATION = 'template' cfgfile = configuration_file(cfgfile) cfg = configobj.ConfigObj(cfgfile, configspec=cfgspec, encoding='utf-8') validator = ...
[ "Update", "configuration", "from", "file", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/config.py#L75-L97
[ "def", "update_configuration", "(", "cfgfile", "=", "None", ")", ":", "configobj", ".", "DEFAULT_INTERPOLATION", "=", "'template'", "cfgfile", "=", "configuration_file", "(", "cfgfile", ")", "cfg", "=", "configobj", ".", "ConfigObj", "(", "cfgfile", ",", "config...
c89b168d4780d157e1b3f7676628c1b131956a88
test
check
Check configuration for sanity.
pyca/config.py
def check(): '''Check configuration for sanity. ''' if config('server')['insecure']: logger.warning('HTTPS CHECKS ARE TURNED OFF. A SECURE CONNECTION IS ' 'NOT GUARANTEED') if config('server')['certificate']: # Ensure certificate exists and is readable open...
def check(): '''Check configuration for sanity. ''' if config('server')['insecure']: logger.warning('HTTPS CHECKS ARE TURNED OFF. A SECURE CONNECTION IS ' 'NOT GUARANTEED') if config('server')['certificate']: # Ensure certificate exists and is readable open...
[ "Check", "configuration", "for", "sanity", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/config.py#L100-L111
[ "def", "check", "(", ")", ":", "if", "config", "(", "'server'", ")", "[", "'insecure'", "]", ":", "logger", ".", "warning", "(", "'HTTPS CHECKS ARE TURNED OFF. A SECURE CONNECTION IS '", "'NOT GUARANTEED'", ")", "if", "config", "(", "'server'", ")", "[", "'certi...
c89b168d4780d157e1b3f7676628c1b131956a88
test
logger_init
Initialize logger based on configuration
pyca/config.py
def logger_init(): '''Initialize logger based on configuration ''' handlers = [] logconf = config('logging') if logconf['syslog']: handlers.append(logging.handlers.SysLogHandler(address='/dev/log')) if logconf['stderr']: handlers.append(logging.StreamHandler(sys.stderr)) if l...
def logger_init(): '''Initialize logger based on configuration ''' handlers = [] logconf = config('logging') if logconf['syslog']: handlers.append(logging.handlers.SysLogHandler(address='/dev/log')) if logconf['stderr']: handlers.append(logging.StreamHandler(sys.stderr)) if l...
[ "Initialize", "logger", "based", "on", "configuration" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/config.py#L119-L135
[ "def", "logger_init", "(", ")", ":", "handlers", "=", "[", "]", "logconf", "=", "config", "(", "'logging'", ")", "if", "logconf", "[", "'syslog'", "]", ":", "handlers", ".", "append", "(", "logging", ".", "handlers", ".", "SysLogHandler", "(", "address",...
c89b168d4780d157e1b3f7676628c1b131956a88
test
home
Serve the status page of the capture agent.
pyca/ui/__init__.py
def home(): '''Serve the status page of the capture agent. ''' # Get IDs of existing preview images preview = config()['capture']['preview'] previewdir = config()['capture']['preview_dir'] preview = [p.replace('{{previewdir}}', previewdir) for p in preview] preview = zip(preview, range(len(p...
def home(): '''Serve the status page of the capture agent. ''' # Get IDs of existing preview images preview = config()['capture']['preview'] previewdir = config()['capture']['preview_dir'] preview = [p.replace('{{previewdir}}', previewdir) for p in preview] preview = zip(preview, range(len(p...
[ "Serve", "the", "status", "page", "of", "the", "capture", "agent", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/__init__.py#L18-L55
[ "def", "home", "(", ")", ":", "# Get IDs of existing preview images", "preview", "=", "config", "(", ")", "[", "'capture'", "]", "[", "'preview'", "]", "previewdir", "=", "config", "(", ")", "[", "'capture'", "]", "[", "'preview_dir'", "]", "preview", "=", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
serve_image
Serve the preview image with the given id
pyca/ui/__init__.py
def serve_image(image_id): '''Serve the preview image with the given id ''' try: preview_dir = config()['capture']['preview_dir'] filepath = config()['capture']['preview'][image_id] filepath = filepath.replace('{{previewdir}}', preview_dir) filepath = os.path.abspath(filepath...
def serve_image(image_id): '''Serve the preview image with the given id ''' try: preview_dir = config()['capture']['preview_dir'] filepath = config()['capture']['preview'][image_id] filepath = filepath.replace('{{previewdir}}', preview_dir) filepath = os.path.abspath(filepath...
[ "Serve", "the", "preview", "image", "with", "the", "given", "id" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/__init__.py#L60-L73
[ "def", "serve_image", "(", "image_id", ")", ":", "try", ":", "preview_dir", "=", "config", "(", ")", "[", "'capture'", "]", "[", "'preview_dir'", "]", "filepath", "=", "config", "(", ")", "[", "'capture'", "]", "[", "'preview'", "]", "[", "image_id", "...
c89b168d4780d157e1b3f7676628c1b131956a88
test
sigterm_handler
Intercept sigterm and terminate all processes.
pyca/__main__.py
def sigterm_handler(signum, frame): '''Intercept sigterm and terminate all processes. ''' sigint_handler(signum, frame) for process in multiprocessing.active_children(): process.terminate() sys.exit(0)
def sigterm_handler(signum, frame): '''Intercept sigterm and terminate all processes. ''' sigint_handler(signum, frame) for process in multiprocessing.active_children(): process.terminate() sys.exit(0)
[ "Intercept", "sigterm", "and", "terminate", "all", "processes", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/__main__.py#L52-L58
[ "def", "sigterm_handler", "(", "signum", ",", "frame", ")", ":", "sigint_handler", "(", "signum", ",", "frame", ")", "for", "process", "in", "multiprocessing", ".", "active_children", "(", ")", ":", "process", ".", "terminate", "(", ")", "sys", ".", "exit"...
c89b168d4780d157e1b3f7676628c1b131956a88
test
run_all
Start all services.
pyca/__main__.py
def run_all(*modules): '''Start all services. ''' processes = [multiprocessing.Process(target=mod.run) for mod in modules] for p in processes: p.start() for p in processes: p.join()
def run_all(*modules): '''Start all services. ''' processes = [multiprocessing.Process(target=mod.run) for mod in modules] for p in processes: p.start() for p in processes: p.join()
[ "Start", "all", "services", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/__main__.py#L61-L68
[ "def", "run_all", "(", "*", "modules", ")", ":", "processes", "=", "[", "multiprocessing", ".", "Process", "(", "target", "=", "mod", ".", "run", ")", "for", "mod", "in", "modules", "]", "for", "p", "in", "processes", ":", "p", ".", "start", "(", "...
c89b168d4780d157e1b3f7676628c1b131956a88
test
parse_ical
Parse Opencast schedule iCalendar file and return events as dict
pyca/schedule.py
def parse_ical(vcal): '''Parse Opencast schedule iCalendar file and return events as dict ''' vcal = vcal.replace('\r\n ', '').replace('\r\n\r\n', '\r\n') vevents = vcal.split('\r\nBEGIN:VEVENT\r\n') del(vevents[0]) events = [] for vevent in vevents: event = {} for line in ve...
def parse_ical(vcal): '''Parse Opencast schedule iCalendar file and return events as dict ''' vcal = vcal.replace('\r\n ', '').replace('\r\n\r\n', '\r\n') vevents = vcal.split('\r\nBEGIN:VEVENT\r\n') del(vevents[0]) events = [] for vevent in vevents: event = {} for line in ve...
[ "Parse", "Opencast", "schedule", "iCalendar", "file", "and", "return", "events", "as", "dict" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/schedule.py#L32-L61
[ "def", "parse_ical", "(", "vcal", ")", ":", "vcal", "=", "vcal", ".", "replace", "(", "'\\r\\n '", ",", "''", ")", ".", "replace", "(", "'\\r\\n\\r\\n'", ",", "'\\r\\n'", ")", "vevents", "=", "vcal", ".", "split", "(", "'\\r\\nBEGIN:VEVENT\\r\\n'", ")", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
get_schedule
Try to load schedule from the Matterhorn core. Returns a valid schedule or None on failure.
pyca/schedule.py
def get_schedule(): '''Try to load schedule from the Matterhorn core. Returns a valid schedule or None on failure. ''' params = {'agentid': config()['agent']['name'].encode('utf8')} lookahead = config()['agent']['cal_lookahead'] * 24 * 60 * 60 if lookahead: params['cutoff'] = str((timest...
def get_schedule(): '''Try to load schedule from the Matterhorn core. Returns a valid schedule or None on failure. ''' params = {'agentid': config()['agent']['name'].encode('utf8')} lookahead = config()['agent']['cal_lookahead'] * 24 * 60 * 60 if lookahead: params['cutoff'] = str((timest...
[ "Try", "to", "load", "schedule", "from", "the", "Matterhorn", "core", ".", "Returns", "a", "valid", "schedule", "or", "None", "on", "failure", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/schedule.py#L64-L99
[ "def", "get_schedule", "(", ")", ":", "params", "=", "{", "'agentid'", ":", "config", "(", ")", "[", "'agent'", "]", "[", "'name'", "]", ".", "encode", "(", "'utf8'", ")", "}", "lookahead", "=", "config", "(", ")", "[", "'agent'", "]", "[", "'cal_l...
c89b168d4780d157e1b3f7676628c1b131956a88
test
control_loop
Main loop, retrieving the schedule.
pyca/schedule.py
def control_loop(): '''Main loop, retrieving the schedule. ''' set_service_status(Service.SCHEDULE, ServiceStatus.BUSY) notify.notify('READY=1') while not terminate(): notify.notify('WATCHDOG=1') # Try getting an updated schedule get_schedule() session = get_session()...
def control_loop(): '''Main loop, retrieving the schedule. ''' set_service_status(Service.SCHEDULE, ServiceStatus.BUSY) notify.notify('READY=1') while not terminate(): notify.notify('WATCHDOG=1') # Try getting an updated schedule get_schedule() session = get_session()...
[ "Main", "loop", "retrieving", "the", "schedule", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/schedule.py#L102-L131
[ "def", "control_loop", "(", ")", ":", "set_service_status", "(", "Service", ".", "SCHEDULE", ",", "ServiceStatus", ".", "BUSY", ")", "notify", ".", "notify", "(", "'READY=1'", ")", "while", "not", "terminate", "(", ")", ":", "notify", ".", "notify", "(", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
control_loop
Main loop, updating the capture agent state.
pyca/agentstate.py
def control_loop(): '''Main loop, updating the capture agent state. ''' set_service_status(Service.AGENTSTATE, ServiceStatus.BUSY) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): notify.notify('WATCHDOG=1') update_agent_state() next_update...
def control_loop(): '''Main loop, updating the capture agent state. ''' set_service_status(Service.AGENTSTATE, ServiceStatus.BUSY) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): notify.notify('WATCHDOG=1') update_agent_state() next_update...
[ "Main", "loop", "updating", "the", "capture", "agent", "state", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/agentstate.py#L22-L37
[ "def", "control_loop", "(", ")", ":", "set_service_status", "(", "Service", ".", "AGENTSTATE", ",", "ServiceStatus", ".", "BUSY", ")", "notify", ".", "notify", "(", "'READY=1'", ")", "notify", ".", "notify", "(", "'STATUS=Running'", ")", "while", "not", "ter...
c89b168d4780d157e1b3f7676628c1b131956a88
test
make_error_response
Return a response with a jsonapi error object
pyca/ui/jsonapi.py
def make_error_response(error, status=500): ''' Return a response with a jsonapi error object ''' content = { 'errors': [{ 'status': status, 'title': error }] } return make_response(jsonify(content), status)
def make_error_response(error, status=500): ''' Return a response with a jsonapi error object ''' content = { 'errors': [{ 'status': status, 'title': error }] } return make_response(jsonify(content), status)
[ "Return", "a", "response", "with", "a", "jsonapi", "error", "object" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L14-L23
[ "def", "make_error_response", "(", "error", ",", "status", "=", "500", ")", ":", "content", "=", "{", "'errors'", ":", "[", "{", "'status'", ":", "status", ",", "'title'", ":", "error", "}", "]", "}", "return", "make_response", "(", "jsonify", "(", "co...
c89b168d4780d157e1b3f7676628c1b131956a88
test
make_data_response
Return a response with a list of jsonapi data objects
pyca/ui/jsonapi.py
def make_data_response(data, status=200): ''' Return a response with a list of jsonapi data objects ''' content = {'data': ensurelist(data)} return make_response(jsonify(content), status)
def make_data_response(data, status=200): ''' Return a response with a list of jsonapi data objects ''' content = {'data': ensurelist(data)} return make_response(jsonify(content), status)
[ "Return", "a", "response", "with", "a", "list", "of", "jsonapi", "data", "objects" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L26-L30
[ "def", "make_data_response", "(", "data", ",", "status", "=", "200", ")", ":", "content", "=", "{", "'data'", ":", "ensurelist", "(", "data", ")", "}", "return", "make_response", "(", "jsonify", "(", "content", ")", ",", "status", ")" ]
c89b168d4780d157e1b3f7676628c1b131956a88
test
internal_state
Serve a json representation of internal agentstate as meta data
pyca/ui/jsonapi.py
def internal_state(): '''Serve a json representation of internal agentstate as meta data ''' data = {'services': { 'capture': ServiceStatus.str(get_service_status(Service.CAPTURE)), 'ingest': ServiceStatus.str(get_service_status(Service.INGEST)), 'schedule': ServiceStatus.str(get_ser...
def internal_state(): '''Serve a json representation of internal agentstate as meta data ''' data = {'services': { 'capture': ServiceStatus.str(get_service_status(Service.CAPTURE)), 'ingest': ServiceStatus.str(get_service_status(Service.INGEST)), 'schedule': ServiceStatus.str(get_ser...
[ "Serve", "a", "json", "representation", "of", "internal", "agentstate", "as", "meta", "data" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L36-L46
[ "def", "internal_state", "(", ")", ":", "data", "=", "{", "'services'", ":", "{", "'capture'", ":", "ServiceStatus", ".", "str", "(", "get_service_status", "(", "Service", ".", "CAPTURE", ")", ")", ",", "'ingest'", ":", "ServiceStatus", ".", "str", "(", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
events
Serve a JSON representation of events
pyca/ui/jsonapi.py
def events(): '''Serve a JSON representation of events ''' db = get_session() upcoming_events = db.query(UpcomingEvent)\ .order_by(UpcomingEvent.start) recorded_events = db.query(RecordedEvent)\ .order_by(RecordedEvent.start.desc()) result = [even...
def events(): '''Serve a JSON representation of events ''' db = get_session() upcoming_events = db.query(UpcomingEvent)\ .order_by(UpcomingEvent.start) recorded_events = db.query(RecordedEvent)\ .order_by(RecordedEvent.start.desc()) result = [even...
[ "Serve", "a", "JSON", "representation", "of", "events" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L52-L63
[ "def", "events", "(", ")", ":", "db", "=", "get_session", "(", ")", "upcoming_events", "=", "db", ".", "query", "(", "UpcomingEvent", ")", ".", "order_by", "(", "UpcomingEvent", ".", "start", ")", "recorded_events", "=", "db", ".", "query", "(", "Recorde...
c89b168d4780d157e1b3f7676628c1b131956a88
test
event
Return a specific events JSON
pyca/ui/jsonapi.py
def event(uid): '''Return a specific events JSON ''' db = get_session() event = db.query(RecordedEvent).filter(RecordedEvent.uid == uid).first() \ or db.query(UpcomingEvent).filter(UpcomingEvent.uid == uid).first() if event: return make_data_response(event.serialize()) return ma...
def event(uid): '''Return a specific events JSON ''' db = get_session() event = db.query(RecordedEvent).filter(RecordedEvent.uid == uid).first() \ or db.query(UpcomingEvent).filter(UpcomingEvent.uid == uid).first() if event: return make_data_response(event.serialize()) return ma...
[ "Return", "a", "specific", "events", "JSON" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L69-L78
[ "def", "event", "(", "uid", ")", ":", "db", "=", "get_session", "(", ")", "event", "=", "db", ".", "query", "(", "RecordedEvent", ")", ".", "filter", "(", "RecordedEvent", ".", "uid", "==", "uid", ")", ".", "first", "(", ")", "or", "db", ".", "qu...
c89b168d4780d157e1b3f7676628c1b131956a88
test
delete_event
Delete a specific event identified by its uid. Note that only recorded events can be deleted. Events in the buffer for upcoming events are regularly replaced anyway and a manual removal could have unpredictable effects. Use ?hard=true parameter to delete the recorded files on disk as well. Returns...
pyca/ui/jsonapi.py
def delete_event(uid): '''Delete a specific event identified by its uid. Note that only recorded events can be deleted. Events in the buffer for upcoming events are regularly replaced anyway and a manual removal could have unpredictable effects. Use ?hard=true parameter to delete the recorded files...
def delete_event(uid): '''Delete a specific event identified by its uid. Note that only recorded events can be deleted. Events in the buffer for upcoming events are regularly replaced anyway and a manual removal could have unpredictable effects. Use ?hard=true parameter to delete the recorded files...
[ "Delete", "a", "specific", "event", "identified", "by", "its", "uid", ".", "Note", "that", "only", "recorded", "events", "can", "be", "deleted", ".", "Events", "in", "the", "buffer", "for", "upcoming", "events", "are", "regularly", "replaced", "anyway", "and...
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L84-L106
[ "def", "delete_event", "(", "uid", ")", ":", "logger", ".", "info", "(", "'deleting event %s via api'", ",", "uid", ")", "db", "=", "get_session", "(", ")", "events", "=", "db", ".", "query", "(", "RecordedEvent", ")", ".", "filter", "(", "RecordedEvent", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
modify_event
Modify an event specified by its uid. The modifications for the event are expected as JSON with the content type correctly set in the request. Note that this method works for recorded events only. Upcoming events part of the scheduler cache cannot be modified.
pyca/ui/jsonapi.py
def modify_event(uid): '''Modify an event specified by its uid. The modifications for the event are expected as JSON with the content type correctly set in the request. Note that this method works for recorded events only. Upcoming events part of the scheduler cache cannot be modified. ''' try:...
def modify_event(uid): '''Modify an event specified by its uid. The modifications for the event are expected as JSON with the content type correctly set in the request. Note that this method works for recorded events only. Upcoming events part of the scheduler cache cannot be modified. ''' try:...
[ "Modify", "an", "event", "specified", "by", "its", "uid", ".", "The", "modifications", "for", "the", "event", "are", "expected", "as", "JSON", "with", "the", "content", "type", "correctly", "set", "in", "the", "request", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ui/jsonapi.py#L112-L144
[ "def", "modify_event", "(", "uid", ")", ":", "try", ":", "data", "=", "request", ".", "get_json", "(", ")", "[", "'data'", "]", "[", "0", "]", "if", "data", "[", "'type'", "]", "!=", "'event'", "or", "data", "[", "'id'", "]", "!=", "uid", ":", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
get_config_params
Extract the set of configuration parameters from the properties attached to the schedule
pyca/ingest.py
def get_config_params(properties): '''Extract the set of configuration parameters from the properties attached to the schedule ''' param = [] wdef = '' for prop in properties.split('\n'): if prop.startswith('org.opencastproject.workflow.config'): key, val = prop.split('=', 1)...
def get_config_params(properties): '''Extract the set of configuration parameters from the properties attached to the schedule ''' param = [] wdef = '' for prop in properties.split('\n'): if prop.startswith('org.opencastproject.workflow.config'): key, val = prop.split('=', 1)...
[ "Extract", "the", "set", "of", "configuration", "parameters", "from", "the", "properties", "attached", "to", "the", "schedule" ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ingest.py#L26-L39
[ "def", "get_config_params", "(", "properties", ")", ":", "param", "=", "[", "]", "wdef", "=", "''", "for", "prop", "in", "properties", ".", "split", "(", "'\\n'", ")", ":", "if", "prop", ".", "startswith", "(", "'org.opencastproject.workflow.config'", ")", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
ingest
Ingest a finished recording to the Opencast server.
pyca/ingest.py
def ingest(event): '''Ingest a finished recording to the Opencast server. ''' # Update status set_service_status(Service.INGEST, ServiceStatus.BUSY) notify.notify('STATUS=Uploading') recording_state(event.uid, 'uploading') update_event_status(event, Status.UPLOADING) # Select ingest ser...
def ingest(event): '''Ingest a finished recording to the Opencast server. ''' # Update status set_service_status(Service.INGEST, ServiceStatus.BUSY) notify.notify('STATUS=Uploading') recording_state(event.uid, 'uploading') update_event_status(event, Status.UPLOADING) # Select ingest ser...
[ "Ingest", "a", "finished", "recording", "to", "the", "Opencast", "server", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ingest.py#L42-L105
[ "def", "ingest", "(", "event", ")", ":", "# Update status", "set_service_status", "(", "Service", ".", "INGEST", ",", "ServiceStatus", ".", "BUSY", ")", "notify", ".", "notify", "(", "'STATUS=Uploading'", ")", "recording_state", "(", "event", ".", "uid", ",", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
safe_start_ingest
Start a capture process but make sure to catch any errors during this process, log them but otherwise ignore them.
pyca/ingest.py
def safe_start_ingest(event): '''Start a capture process but make sure to catch any errors during this process, log them but otherwise ignore them. ''' try: ingest(event) except Exception: logger.error('Something went wrong during the upload') logger.error(traceback.format_ex...
def safe_start_ingest(event): '''Start a capture process but make sure to catch any errors during this process, log them but otherwise ignore them. ''' try: ingest(event) except Exception: logger.error('Something went wrong during the upload') logger.error(traceback.format_ex...
[ "Start", "a", "capture", "process", "but", "make", "sure", "to", "catch", "any", "errors", "during", "this", "process", "log", "them", "but", "otherwise", "ignore", "them", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ingest.py#L108-L120
[ "def", "safe_start_ingest", "(", "event", ")", ":", "try", ":", "ingest", "(", "event", ")", "except", "Exception", ":", "logger", ".", "error", "(", "'Something went wrong during the upload'", ")", "logger", ".", "error", "(", "traceback", ".", "format_exc", ...
c89b168d4780d157e1b3f7676628c1b131956a88
test
control_loop
Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry.
pyca/ingest.py
def control_loop(): '''Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry. ''' set_service_status(Service.INGEST, ServiceStatus.IDLE) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): ...
def control_loop(): '''Main loop of the capture agent, retrieving and checking the schedule as well as starting the capture process if necessry. ''' set_service_status(Service.INGEST, ServiceStatus.IDLE) notify.notify('READY=1') notify.notify('STATUS=Running') while not terminate(): ...
[ "Main", "loop", "of", "the", "capture", "agent", "retrieving", "and", "checking", "the", "schedule", "as", "well", "as", "starting", "the", "capture", "process", "if", "necessry", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/ingest.py#L123-L140
[ "def", "control_loop", "(", ")", ":", "set_service_status", "(", "Service", ".", "INGEST", ",", "ServiceStatus", ".", "IDLE", ")", "notify", ".", "notify", "(", "'READY=1'", ")", "notify", ".", "notify", "(", "'STATUS=Running'", ")", "while", "not", "termina...
c89b168d4780d157e1b3f7676628c1b131956a88
test
sigterm_handler
Intercept sigterm and terminate all processes.
pyca/capture.py
def sigterm_handler(signum, frame): '''Intercept sigterm and terminate all processes. ''' if captureproc and captureproc.poll() is None: captureproc.terminate() terminate(True) sys.exit(0)
def sigterm_handler(signum, frame): '''Intercept sigterm and terminate all processes. ''' if captureproc and captureproc.poll() is None: captureproc.terminate() terminate(True) sys.exit(0)
[ "Intercept", "sigterm", "and", "terminate", "all", "processes", "." ]
opencast/pyCA
python
https://github.com/opencast/pyCA/blob/c89b168d4780d157e1b3f7676628c1b131956a88/pyca/capture.py#L32-L38
[ "def", "sigterm_handler", "(", "signum", ",", "frame", ")", ":", "if", "captureproc", "and", "captureproc", ".", "poll", "(", ")", "is", "None", ":", "captureproc", ".", "terminate", "(", ")", "terminate", "(", "True", ")", "sys", ".", "exit", "(", "0"...
c89b168d4780d157e1b3f7676628c1b131956a88