repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
vfilimonov/pydatastream
pydatastream/pydatastream.py
Datastream.fetch
def fetch(self, tickers, fields=None, date=None, date_from=None, date_to=None, freq='D', only_data=True, static=False): """Fetch data from TR DWE. tickers - ticker or list of tickers fields - list of fields. date - date for a single-date query date_...
python
def fetch(self, tickers, fields=None, date=None, date_from=None, date_to=None, freq='D', only_data=True, static=False): """Fetch data from TR DWE. tickers - ticker or list of tickers fields - list of fields. date - date for a single-date query date_...
[ "def", "fetch", "(", "self", ",", "tickers", ",", "fields", "=", "None", ",", "date", "=", "None", ",", "date_from", "=", "None", ",", "date_to", "=", "None", ",", "freq", "=", "'D'", ",", "only_data", "=", "True", ",", "static", "=", "False", ")",...
Fetch data from TR DWE. tickers - ticker or list of tickers fields - list of fields. date - date for a single-date query date_from, date_to - date range (used only if "date" is not specified) freq - frequency of data: daily('D'), weekly('W') or monthly('M')...
[ "Fetch", "data", "from", "TR", "DWE", "." ]
train
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L465-L525
vfilimonov/pydatastream
pydatastream/pydatastream.py
Datastream.get_OHLCV
def get_OHLCV(self, ticker, date=None, date_from=None, date_to=None): """Get Open, High, Low, Close prices and daily Volume for a given ticker. ticker - ticker or symbol date - date for a single-date query date_from, date_to - date range (used only if "date" is not specifie...
python
def get_OHLCV(self, ticker, date=None, date_from=None, date_to=None): """Get Open, High, Low, Close prices and daily Volume for a given ticker. ticker - ticker or symbol date - date for a single-date query date_from, date_to - date range (used only if "date" is not specifie...
[ "def", "get_OHLCV", "(", "self", ",", "ticker", ",", "date", "=", "None", ",", "date_from", "=", "None", ",", "date_to", "=", "None", ")", ":", "data", ",", "meta", "=", "self", ".", "fetch", "(", "ticker", "+", "\"~OHLCV\"", ",", "None", ",", "dat...
Get Open, High, Low, Close prices and daily Volume for a given ticker. ticker - ticker or symbol date - date for a single-date query date_from, date_to - date range (used only if "date" is not specified) Returns pandas.Dataframe with data. If error occurs, then it is pr...
[ "Get", "Open", "High", "Low", "Close", "prices", "and", "daily", "Volume", "for", "a", "given", "ticker", "." ]
train
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L528-L540
vfilimonov/pydatastream
pydatastream/pydatastream.py
Datastream.get_constituents
def get_constituents(self, index_ticker, date=None, only_list=False): """ Get a list of all constituents of a given index. index_ticker - Datastream ticker for index date - date for which list should be retrieved (if None then list of present constitue...
python
def get_constituents(self, index_ticker, date=None, only_list=False): """ Get a list of all constituents of a given index. index_ticker - Datastream ticker for index date - date for which list should be retrieved (if None then list of present constitue...
[ "def", "get_constituents", "(", "self", ",", "index_ticker", ",", "date", "=", "None", ",", "only_list", "=", "False", ")", ":", "if", "date", "is", "not", "None", ":", "str_date", "=", "pd", ".", "to_datetime", "(", "date", ")", ".", "strftime", "(", ...
Get a list of all constituents of a given index. index_ticker - Datastream ticker for index date - date for which list should be retrieved (if None then list of present constituents is retrieved) only_list - request only list of symbols. By defa...
[ "Get", "a", "list", "of", "all", "constituents", "of", "a", "given", "index", "." ]
train
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L571-L595
vfilimonov/pydatastream
pydatastream/pydatastream.py
Datastream.get_epit_vintage_matrix
def get_epit_vintage_matrix(self, mnemonic, date_from='1951-01-01', date_to=None): """ Construct the vintage matrix for a given economic series. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). Vintage matrix represents a DataFrame where columns correspond to a ...
python
def get_epit_vintage_matrix(self, mnemonic, date_from='1951-01-01', date_to=None): """ Construct the vintage matrix for a given economic series. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). Vintage matrix represents a DataFrame where columns correspond to a ...
[ "def", "get_epit_vintage_matrix", "(", "self", ",", "mnemonic", ",", "date_from", "=", "'1951-01-01'", ",", "date_to", "=", "None", ")", ":", "# Get first available date from the REL1 series", "rel1", "=", "self", ".", "fetch", "(", "mnemonic", ",", "'REL1'", ",",...
Construct the vintage matrix for a given economic series. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). Vintage matrix represents a DataFrame where columns correspond to a particular period (quarter or month) for the reported statistic and index...
[ "Construct", "the", "vintage", "matrix", "for", "a", "given", "economic", "series", ".", "Requires", "subscription", "to", "Thomson", "Reuters", "Economic", "Point", "-", "in", "-", "Time", "(", "EPiT", ")", "." ]
train
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L598-L646
vfilimonov/pydatastream
pydatastream/pydatastream.py
Datastream.get_epit_revisions
def get_epit_revisions(self, mnemonic, period, relh50=False): """ Return initial estimate and first revisions of a given economic time series and a given period. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). "Period" parameter should represent a dat...
python
def get_epit_revisions(self, mnemonic, period, relh50=False): """ Return initial estimate and first revisions of a given economic time series and a given period. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). "Period" parameter should represent a dat...
[ "def", "get_epit_revisions", "(", "self", ",", "mnemonic", ",", "period", ",", "relh50", "=", "False", ")", ":", "if", "relh50", ":", "data", "=", "self", ".", "fetch", "(", "mnemonic", ",", "'RELH50'", ",", "date", "=", "period", ",", "static", "=", ...
Return initial estimate and first revisions of a given economic time series and a given period. Requires subscription to Thomson Reuters Economic Point-in-Time (EPiT). "Period" parameter should represent a date which falls within a time period of interest, e.g. 2016 Q4 c...
[ "Return", "initial", "estimate", "and", "first", "revisions", "of", "a", "given", "economic", "time", "series", "and", "a", "given", "period", ".", "Requires", "subscription", "to", "Thomson", "Reuters", "Economic", "Point", "-", "in", "-", "Time", "(", "EPi...
train
https://github.com/vfilimonov/pydatastream/blob/15d2adac1c83501715db1542373fa8428542816e/pydatastream/pydatastream.py#L649-L672
crs4/hl7apy
hl7apy/__init__.py
check_encoding_chars
def check_encoding_chars(encoding_chars): """ Validate the given encoding chars :type encoding_chars: ``dict`` :param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`) :raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid ...
python
def check_encoding_chars(encoding_chars): """ Validate the given encoding chars :type encoding_chars: ``dict`` :param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`) :raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid ...
[ "def", "check_encoding_chars", "(", "encoding_chars", ")", ":", "if", "not", "isinstance", "(", "encoding_chars", ",", "collections", ".", "MutableMapping", ")", ":", "raise", "InvalidEncodingChars", "required", "=", "{", "'FIELD'", ",", "'COMPONENT'", ",", "'SUBC...
Validate the given encoding chars :type encoding_chars: ``dict`` :param encoding_chars: the encoding chars (see :func:`hl7apy.set_default_encoding_chars`) :raises: :exc:`hl7apy.exceptions.InvalidEncodingChars` if the given encoding chars are not valid
[ "Validate", "the", "given", "encoding", "chars" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L46-L63
crs4/hl7apy
hl7apy/__init__.py
check_validation_level
def check_validation_level(validation_level): """ Validate the given validation level :type validation_level: ``int`` :param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`) :raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is uns...
python
def check_validation_level(validation_level): """ Validate the given validation level :type validation_level: ``int`` :param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`) :raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is uns...
[ "def", "check_validation_level", "(", "validation_level", ")", ":", "if", "validation_level", "not", "in", "(", "VALIDATION_LEVEL", ".", "QUIET", ",", "VALIDATION_LEVEL", ".", "STRICT", ",", "VALIDATION_LEVEL", ".", "TOLERANT", ")", ":", "raise", "UnknownValidationL...
Validate the given validation level :type validation_level: ``int`` :param validation_level: validation level (see :class:`hl7apy.consts.VALIDATION_LEVEL`) :raises: :exc:`hl7apy.exceptions.UnknownValidationLevel` if the given validation level is unsupported
[ "Validate", "the", "given", "validation", "level" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L66-L75
crs4/hl7apy
hl7apy/__init__.py
load_library
def load_library(version): """ Load the correct module according to the version :type version: ``str`` :param version: the version of the library to be loaded (e.g. '2.6') :rtype: module object """ check_version(version) module_name = SUPPORTED_LIBRARIES[version] lib = sys.modules.g...
python
def load_library(version): """ Load the correct module according to the version :type version: ``str`` :param version: the version of the library to be loaded (e.g. '2.6') :rtype: module object """ check_version(version) module_name = SUPPORTED_LIBRARIES[version] lib = sys.modules.g...
[ "def", "load_library", "(", "version", ")", ":", "check_version", "(", "version", ")", "module_name", "=", "SUPPORTED_LIBRARIES", "[", "version", "]", "lib", "=", "sys", ".", "modules", ".", "get", "(", "module_name", ")", "if", "lib", "is", "None", ":", ...
Load the correct module according to the version :type version: ``str`` :param version: the version of the library to be loaded (e.g. '2.6') :rtype: module object
[ "Load", "the", "correct", "module", "according", "to", "the", "version" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L223-L236
crs4/hl7apy
hl7apy/__init__.py
load_reference
def load_reference(name, element_type, version): """ Look for an element of the given type, name and version and return its reference structure :type element_type: ``str`` :param element_type: the element type to look for (e.g. 'Segment') :type name: ``str`` :param name: the element name to loo...
python
def load_reference(name, element_type, version): """ Look for an element of the given type, name and version and return its reference structure :type element_type: ``str`` :param element_type: the element type to look for (e.g. 'Segment') :type name: ``str`` :param name: the element name to loo...
[ "def", "load_reference", "(", "name", ",", "element_type", ",", "version", ")", ":", "lib", "=", "load_library", "(", "version", ")", "ref", "=", "lib", ".", "get", "(", "name", ",", "element_type", ")", "return", "ref" ]
Look for an element of the given type, name and version and return its reference structure :type element_type: ``str`` :param element_type: the element type to look for (e.g. 'Segment') :type name: ``str`` :param name: the element name to look for (e.g. 'MSH') :type version: ``str`` :param vers...
[ "Look", "for", "an", "element", "of", "the", "given", "type", "name", "and", "version", "and", "return", "its", "reference", "structure" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L239-L281
crs4/hl7apy
hl7apy/__init__.py
find_reference
def find_reference(name, element_types, version): """ Look for an element of the given name and version into the given types and return its reference structure :type name: ``str`` :param name: the element name to look for (e.g. 'MSH') :type types: ``list`` or ``tuple`` :param types: the element...
python
def find_reference(name, element_types, version): """ Look for an element of the given name and version into the given types and return its reference structure :type name: ``str`` :param name: the element name to look for (e.g. 'MSH') :type types: ``list`` or ``tuple`` :param types: the element...
[ "def", "find_reference", "(", "name", ",", "element_types", ",", "version", ")", ":", "lib", "=", "load_library", "(", "version", ")", "ref", "=", "lib", ".", "find", "(", "name", ",", "element_types", ")", "return", "ref" ]
Look for an element of the given name and version into the given types and return its reference structure :type name: ``str`` :param name: the element name to look for (e.g. 'MSH') :type types: ``list`` or ``tuple`` :param types: the element classes where to look for the element (e.g. (Group, Segment))...
[ "Look", "for", "an", "element", "of", "the", "given", "name", "and", "version", "into", "the", "given", "types", "and", "return", "its", "reference", "structure" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/__init__.py#L284-L313
crs4/hl7apy
hl7apy/v2_3_1/__init__.py
find
def find(name, where): """ >>> from hl7apy.core import Segment >>> from hl7apy import find_reference >>> find_reference('UNKNOWN', (Segment, ), '2.3.1') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... ChildNotFound: No child named UNKNOWN """ for cls in wh...
python
def find(name, where): """ >>> from hl7apy.core import Segment >>> from hl7apy import find_reference >>> find_reference('UNKNOWN', (Segment, ), '2.3.1') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... ChildNotFound: No child named UNKNOWN """ for cls in wh...
[ "def", "find", "(", "name", ",", "where", ")", ":", "for", "cls", "in", "where", ":", "try", ":", "return", "{", "'ref'", ":", "get", "(", "name", ",", "cls", ".", "__name__", ")", ",", "'name'", ":", "name", ",", "'cls'", ":", "cls", "}", "exc...
>>> from hl7apy.core import Segment >>> from hl7apy import find_reference >>> find_reference('UNKNOWN', (Segment, ), '2.3.1') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... ChildNotFound: No child named UNKNOWN
[ ">>>", "from", "hl7apy", ".", "core", "import", "Segment", ">>>", "from", "hl7apy", "import", "find_reference", ">>>", "find_reference", "(", "UNKNOWN", "(", "Segment", ")", "2", ".", "3", ".", "1", ")", "#", "doctest", ":", "+", "IGNORE_EXCEPTION_DETAIL", ...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/v2_3_1/__init__.py#L46-L60
crs4/hl7apy
hl7apy/utils.py
get_date_info
def get_date_info(value): """ Returns the datetime object and the format of the date in input :type value: `str` """ fmt = _get_date_format(value) dt_value = _datetime_obj_factory(value, fmt) return dt_value, fmt
python
def get_date_info(value): """ Returns the datetime object and the format of the date in input :type value: `str` """ fmt = _get_date_format(value) dt_value = _datetime_obj_factory(value, fmt) return dt_value, fmt
[ "def", "get_date_info", "(", "value", ")", ":", "fmt", "=", "_get_date_format", "(", "value", ")", "dt_value", "=", "_datetime_obj_factory", "(", "value", ",", "fmt", ")", "return", "dt_value", ",", "fmt" ]
Returns the datetime object and the format of the date in input :type value: `str`
[ "Returns", "the", "datetime", "object", "and", "the", "format", "of", "the", "date", "in", "input" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L70-L78
crs4/hl7apy
hl7apy/utils.py
get_timestamp_info
def get_timestamp_info(value): """ Returns the datetime object, the format, the offset and the microsecond of the timestamp in input :type value: `str` """ value, offset = _split_offset(value) fmt, microsec = _get_timestamp_format(value) dt_value = _datetime_obj_factory(value, fmt) retu...
python
def get_timestamp_info(value): """ Returns the datetime object, the format, the offset and the microsecond of the timestamp in input :type value: `str` """ value, offset = _split_offset(value) fmt, microsec = _get_timestamp_format(value) dt_value = _datetime_obj_factory(value, fmt) retu...
[ "def", "get_timestamp_info", "(", "value", ")", ":", "value", ",", "offset", "=", "_split_offset", "(", "value", ")", "fmt", ",", "microsec", "=", "_get_timestamp_format", "(", "value", ")", "dt_value", "=", "_datetime_obj_factory", "(", "value", ",", "fmt", ...
Returns the datetime object, the format, the offset and the microsecond of the timestamp in input :type value: `str`
[ "Returns", "the", "datetime", "object", "the", "format", "the", "offset", "and", "the", "microsecond", "of", "the", "timestamp", "in", "input" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L81-L90
crs4/hl7apy
hl7apy/utils.py
get_datetime_info
def get_datetime_info(value): """ Returns the datetime object, the format, the offset and the microsecond of the datetime in input :type value: `str` """ date_value, offset = _split_offset(value) date_format = _get_date_format(date_value[:8]) try: timestamp_form, microsec = _get_ti...
python
def get_datetime_info(value): """ Returns the datetime object, the format, the offset and the microsecond of the datetime in input :type value: `str` """ date_value, offset = _split_offset(value) date_format = _get_date_format(date_value[:8]) try: timestamp_form, microsec = _get_ti...
[ "def", "get_datetime_info", "(", "value", ")", ":", "date_value", ",", "offset", "=", "_split_offset", "(", "value", ")", "date_format", "=", "_get_date_format", "(", "date_value", "[", ":", "8", "]", ")", "try", ":", "timestamp_form", ",", "microsec", "=", ...
Returns the datetime object, the format, the offset and the microsecond of the datetime in input :type value: `str`
[ "Returns", "the", "datetime", "object", "the", "format", "the", "offset", "and", "the", "microsecond", "of", "the", "datetime", "in", "input" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/utils.py#L93-L112
crs4/hl7apy
hl7apy/core.py
is_base_datatype
def is_base_datatype(datatype, version=None): """ Check if the given datatype is a base datatype of the specified version :type datatype: ``str`` :param datatype: the datatype (e.g. ST) :type version: ``str`` :param version: the HL7 version (e.g. 2.5) :return: ``True`` if it is a base dat...
python
def is_base_datatype(datatype, version=None): """ Check if the given datatype is a base datatype of the specified version :type datatype: ``str`` :param datatype: the datatype (e.g. ST) :type version: ``str`` :param version: the HL7 version (e.g. 2.5) :return: ``True`` if it is a base dat...
[ "def", "is_base_datatype", "(", "datatype", ",", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "version", "=", "get_default_version", "(", ")", "lib", "=", "load_library", "(", "version", ")", "return", "lib", ".", "is_base_datatype",...
Check if the given datatype is a base datatype of the specified version :type datatype: ``str`` :param datatype: the datatype (e.g. ST) :type version: ``str`` :param version: the HL7 version (e.g. 2.5) :return: ``True`` if it is a base datatype, ``False`` otherwise >>> is_base_datatype('ST')...
[ "Check", "if", "the", "given", "datatype", "is", "a", "base", "datatype", "of", "the", "specified", "version" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L59-L79
crs4/hl7apy
hl7apy/core.py
ElementList.get_ordered_children
def get_ordered_children(self): """ Return the list of children ordered according to the element structure :return: a list of :class:`Element <hl7apy.core.Element>` """ ordered_keys = self.element.ordered_children if self.element.ordered_children is not None else [] chil...
python
def get_ordered_children(self): """ Return the list of children ordered according to the element structure :return: a list of :class:`Element <hl7apy.core.Element>` """ ordered_keys = self.element.ordered_children if self.element.ordered_children is not None else [] chil...
[ "def", "get_ordered_children", "(", "self", ")", ":", "ordered_keys", "=", "self", ".", "element", ".", "ordered_children", "if", "self", ".", "element", ".", "ordered_children", "is", "not", "None", "else", "[", "]", "children", "=", "[", "self", ".", "in...
Return the list of children ordered according to the element structure :return: a list of :class:`Element <hl7apy.core.Element>`
[ "Return", "the", "list", "of", "children", "ordered", "according", "to", "the", "element", "structure" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L210-L218
crs4/hl7apy
hl7apy/core.py
ElementList.insert
def insert(self, index, child, by_name_index=-1): """ Add the child at the given index :type index: ``int`` :param index: child position :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass ...
python
def insert(self, index, child, by_name_index=-1): """ Add the child at the given index :type index: ``int`` :param index: child position :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass ...
[ "def", "insert", "(", "self", ",", "index", ",", "child", ",", "by_name_index", "=", "-", "1", ")", ":", "if", "self", ".", "_can_add_child", "(", "child", ")", ":", "try", ":", "if", "by_name_index", "==", "-", "1", ":", "self", ".", "indexes", "[...
Add the child at the given index :type index: ``int`` :param index: child position :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
[ "Add", "the", "child", "at", "the", "given", "index" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L228-L246
crs4/hl7apy
hl7apy/core.py
ElementList.append
def append(self, child): """ Append the given child :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass """ if self._can_add_child(child): if self.element == child.parent: self...
python
def append(self, child): """ Append the given child :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass """ if self._can_add_child(child): if self.element == child.parent: self...
[ "def", "append", "(", "self", ",", "child", ")", ":", "if", "self", ".", "_can_add_child", "(", "child", ")", ":", "if", "self", ".", "element", "==", "child", ".", "parent", ":", "self", ".", "_remove_from_traversal_index", "(", "child", ")", "self", ...
Append the given child :class:`Element <hl7apy.core.Element>` :param child: an instance of an :class:`Element <hl7apy.core.Element>` subclass
[ "Append", "the", "given", "child" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L248-L267
crs4/hl7apy
hl7apy/core.py
ElementList.set
def set(self, name, value, index=-1): """ Assign the ``value`` to the child having the given ``name`` at the ``index`` position :type name: ``str`` :param name: the child name (e.g. PID) :type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ...
python
def set(self, name, value, index=-1): """ Assign the ``value`` to the child having the given ``name`` at the ``index`` position :type name: ``str`` :param name: the child name (e.g. PID) :type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ...
[ "def", "set", "(", "self", ",", "name", ",", "value", ",", "index", "=", "-", "1", ")", ":", "# just copy the first element of the ElementProxy (e.g. message.pid = message2.pid)", "if", "isinstance", "(", "value", ",", "ElementProxy", ")", ":", "value", "=", "valu...
Assign the ``value`` to the child having the given ``name`` at the ``index`` position :type name: ``str`` :param name: the child name (e.g. PID) :type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance of :class:`ElementProxy <hl7apy.core.ElementPr...
[ "Assign", "the", "value", "to", "the", "child", "having", "the", "given", "name", "at", "the", "index", "position" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L285-L329
crs4/hl7apy
hl7apy/core.py
ElementList.remove
def remove(self, child): """ Remove the given child from both child list and child indexes :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of :class:`Element <hl7apy.core.Element>` subclass """ try: if self.element == child.trave...
python
def remove(self, child): """ Remove the given child from both child list and child indexes :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of :class:`Element <hl7apy.core.Element>` subclass """ try: if self.element == child.trave...
[ "def", "remove", "(", "self", ",", "child", ")", ":", "try", ":", "if", "self", ".", "element", "==", "child", ".", "traversal_parent", ":", "self", ".", "_remove_from_traversal_index", "(", "child", ")", "else", ":", "self", ".", "_remove_from_index", "("...
Remove the given child from both child list and child indexes :type child: :class:`Element <hl7apy.core.Element>` :param child: an instance of :class:`Element <hl7apy.core.Element>` subclass
[ "Remove", "the", "given", "child", "from", "both", "child", "list", "and", "child", "indexes" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L331-L345
crs4/hl7apy
hl7apy/core.py
ElementList.remove_by_name
def remove_by_name(self, name, index=0): """ Remove the child having the given name at the given position :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core....
python
def remove_by_name(self, name, index=0): """ Remove the child having the given name at the given position :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core....
[ "def", "remove_by_name", "(", "self", ",", "name", ",", "index", "=", "0", ")", ":", "child", "=", "self", ".", "child_at_index", "(", "name", ",", "index", ")", "self", ".", "remove", "(", "child", ")", "return", "child" ]
Remove the child having the given name at the given position :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core.Element>` subclass
[ "Remove", "the", "child", "having", "the", "given", "name", "at", "the", "given", "position" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L347-L361
crs4/hl7apy
hl7apy/core.py
ElementList.child_at_index
def child_at_index(self, name, index): """ Return the child named `name` at the given index :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core.Element>` subc...
python
def child_at_index(self, name, index): """ Return the child named `name` at the given index :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core.Element>` subc...
[ "def", "child_at_index", "(", "self", ",", "name", ",", "index", ")", ":", "def", "_finder", "(", "n", ",", "i", ")", ":", "try", ":", "return", "self", ".", "indexes", "[", "n", "]", "[", "i", "]", "except", "(", "KeyError", ",", "IndexError", "...
Return the child named `name` at the given index :type name: ``str`` :param name: child name (e.g. PID) :type index: ``int`` :param index: child index :return: an instance of :class:`Element <hl7apy.core.Element>` subclass
[ "Return", "the", "child", "named", "name", "at", "the", "given", "index" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L363-L389
crs4/hl7apy
hl7apy/core.py
ElementList.create_element
def create_element(self, name, traversal_parent=False, reference=None): """ Create an element having the given name :type name: ``str`` :param name: the name of the element to be created (e.g. PID) :type traversal_parent: ``bool`` :param traversal_parent: if ``True``, t...
python
def create_element(self, name, traversal_parent=False, reference=None): """ Create an element having the given name :type name: ``str`` :param name: the name of the element to be created (e.g. PID) :type traversal_parent: ``bool`` :param traversal_parent: if ``True``, t...
[ "def", "create_element", "(", "self", ",", "name", ",", "traversal_parent", "=", "False", ",", "reference", "=", "None", ")", ":", "if", "reference", "is", "None", ":", "reference", "=", "self", ".", "element", ".", "find_child_reference", "(", "name", ")"...
Create an element having the given name :type name: ``str`` :param name: the name of the element to be created (e.g. PID) :type traversal_parent: ``bool`` :param traversal_parent: if ``True``, the parent will be set as temporary for traversal purposes :param reference: the new...
[ "Create", "an", "element", "having", "the", "given", "name" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L403-L433
crs4/hl7apy
hl7apy/core.py
ElementList._find_name
def _find_name(self, name): """ Find the reference of a child having the given name :type name: ``str`` :param name: the child name (e.g. PID) :return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the element has not been...
python
def _find_name(self, name): """ Find the reference of a child having the given name :type name: ``str`` :param name: the child name (e.g. PID) :return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the element has not been...
[ "def", "_find_name", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "element", "=", "self", ".", "element", ".", "find_child_reference", "(", "name", ")", "return", "element", "[", "'name'", "]", "if", "element", "is",...
Find the reference of a child having the given name :type name: ``str`` :param name: the child name (e.g. PID) :return: the element structure (see :func:`load_reference <hl7apy.load_reference>`) or ``None`` if the element has not been found
[ "Find", "the", "reference", "of", "a", "child", "having", "the", "given", "name" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L435-L447
crs4/hl7apy
hl7apy/core.py
ElementList._default_child_lookup
def _default_child_lookup(self, name): """ Return an instance of :class:`ElementProxy <hl7apy.core.ElementProxy>` containing the children found having the given name :type name: ``str`` :param name: the name of the children (e.g. PID) :return: an instance of :class:`Ele...
python
def _default_child_lookup(self, name): """ Return an instance of :class:`ElementProxy <hl7apy.core.ElementProxy>` containing the children found having the given name :type name: ``str`` :param name: the name of the children (e.g. PID) :return: an instance of :class:`Ele...
[ "def", "_default_child_lookup", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "indexes", "or", "name", "in", "self", ".", "traversal_indexes", ":", "try", ":", "return", "self", ".", "proxies", "[", "name", "]", "except", "KeyError...
Return an instance of :class:`ElementProxy <hl7apy.core.ElementProxy>` containing the children found having the given name :type name: ``str`` :param name: the name of the children (e.g. PID) :return: an instance of :class:`ElementProxy <hl7apy.core.ElementProxy>` containing the result...
[ "Return", "an", "instance", "of", ":", "class", ":", "ElementProxy", "<hl7apy", ".", "core", ".", "ElementProxy", ">", "containing", "the", "children", "found", "having", "the", "given", "name" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L449-L472
crs4/hl7apy
hl7apy/core.py
ElementFinder.get_structure
def get_structure(element, reference=None): """ Get the element structure :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference...
python
def get_structure(element, reference=None): """ Get the element structure :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference...
[ "def", "get_structure", "(", "element", ",", "reference", "=", "None", ")", ":", "if", "reference", "is", "None", ":", "try", ":", "reference", "=", "load_reference", "(", "element", ".", "name", ",", "element", ".", "classname", ",", "element", ".", "ve...
Get the element structure :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference>` or from a message profile :return: a dic...
[ "Get", "the", "element", "structure" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L532-L551
crs4/hl7apy
hl7apy/core.py
ElementFinder._parse_structure
def _parse_structure(element, reference): """ Parse the given reference :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference>`...
python
def _parse_structure(element, reference): """ Parse the given reference :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference>`...
[ "def", "_parse_structure", "(", "element", ",", "reference", ")", ":", "data", "=", "{", "'reference'", ":", "reference", "}", "content_type", "=", "reference", "[", "0", "]", "# content type can be sequence, choice or leaf", "if", "content_type", "in", "(", "'seq...
Parse the given reference :type element: :class:`Element <hl7apy.core.Element>` :param element: element having the given reference structure :param reference: the element structure from :func:`load_reference <hl7apy.load_reference>` or from a message profile :return: a dic...
[ "Parse", "the", "given", "reference" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L554-L600
crs4/hl7apy
hl7apy/core.py
Element.to_er7
def to_er7(self, encoding_chars=None, trailing_children=False): """ Returns the HL7 representation of the :class:`Element <hl7apy.core.Element>`. It adds the appropriate separator at the end if needed :type encoding_chars: ``dict`` :param encoding_chars: The encoding chars to us...
python
def to_er7(self, encoding_chars=None, trailing_children=False): """ Returns the HL7 representation of the :class:`Element <hl7apy.core.Element>`. It adds the appropriate separator at the end if needed :type encoding_chars: ``dict`` :param encoding_chars: The encoding chars to us...
[ "def", "to_er7", "(", "self", ",", "encoding_chars", "=", "None", ",", "trailing_children", "=", "False", ")", ":", "if", "encoding_chars", "is", "None", ":", "encoding_chars", "=", "self", ".", "encoding_chars", "child_class", "=", "list", "(", "self", ".",...
Returns the HL7 representation of the :class:`Element <hl7apy.core.Element>`. It adds the appropriate separator at the end if needed :type encoding_chars: ``dict`` :param encoding_chars: The encoding chars to use. If it is ``None`` it uses :attr:`self.encoding_chars`, wh...
[ "Returns", "the", "HL7", "representation", "of", "the", ":", "class", ":", "Element", "<hl7apy", ".", "core", ".", "Element", ">", ".", "It", "adds", "the", "appropriate", "separator", "at", "the", "end", "if", "needed" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L706-L735
crs4/hl7apy
hl7apy/core.py
Element.validate
def validate(self, report_file=None): """ Validate the HL7 element using the :attr:`STRICT <hl7apy.consts.VALIDATION_LEVEL.STRICT>` validation level. It calls the :func:`Validator.validate <hl7apy.validation.Validator.validate>` method passing the reference used in the instantiation of t...
python
def validate(self, report_file=None): """ Validate the HL7 element using the :attr:`STRICT <hl7apy.consts.VALIDATION_LEVEL.STRICT>` validation level. It calls the :func:`Validator.validate <hl7apy.validation.Validator.validate>` method passing the reference used in the instantiation of t...
[ "def", "validate", "(", "self", ",", "report_file", "=", "None", ")", ":", "return", "Validator", ".", "validate", "(", "self", ",", "reference", "=", "self", ".", "reference", ",", "report_file", "=", "report_file", ")" ]
Validate the HL7 element using the :attr:`STRICT <hl7apy.consts.VALIDATION_LEVEL.STRICT>` validation level. It calls the :func:`Validator.validate <hl7apy.validation.Validator.validate>` method passing the reference used in the instantiation of the element. :param: report_file: the report file ...
[ "Validate", "the", "HL7", "element", "using", "the", ":", "attr", ":", "STRICT", "<hl7apy", ".", "consts", ".", "VALIDATION_LEVEL", ".", "STRICT", ">", "validation", "level", ".", "It", "calls", "the", ":", "func", ":", "Validator", ".", "validate", "<hl7a...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L737-L745
crs4/hl7apy
hl7apy/core.py
Element.encoding_chars
def encoding_chars(self): """ A ``dict`` with the encoding chars of the :class:`Element <hl7apy.core.Element>`. If the :class:`Element <hl7apy.core.Element>` has a parent it is the parent's ``encoding_chars`` otherwise the ones returned by :func:`get_default_encoding_chars <hl7ap...
python
def encoding_chars(self): """ A ``dict`` with the encoding chars of the :class:`Element <hl7apy.core.Element>`. If the :class:`Element <hl7apy.core.Element>` has a parent it is the parent's ``encoding_chars`` otherwise the ones returned by :func:`get_default_encoding_chars <hl7ap...
[ "def", "encoding_chars", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "not", "None", ":", "return", "self", ".", "parent", ".", "encoding_chars", "return", "get_default_encoding_chars", "(", "self", ".", "version", ")" ]
A ``dict`` with the encoding chars of the :class:`Element <hl7apy.core.Element>`. If the :class:`Element <hl7apy.core.Element>` has a parent it is the parent's ``encoding_chars`` otherwise the ones returned by :func:`get_default_encoding_chars <hl7apy.get_default_encoding_chars>` The str...
[ "A", "dict", "with", "the", "encoding", "chars", "of", "the", ":", "class", ":", "Element", "<hl7apy", ".", "core", ".", "Element", ">", ".", "If", "the", ":", "class", ":", "Element", "<hl7apy", ".", "core", ".", "Element", ">", "has", "a", "parent"...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L788-L809
crs4/hl7apy
hl7apy/core.py
SubComponent.to_er7
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_de...
python
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_de...
[ "def", "to_er7", "(", "self", ",", "encoding_chars", "=", "None", ",", "trailing_children", "=", "False", ")", ":", "if", "encoding_chars", "is", "None", ":", "encoding_chars", "=", "self", ".", "encoding_chars", "try", ":", "return", "self", ".", "value", ...
Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_default_encoding_chars>`) :type trailing_children: ``bool`` :param tr...
[ "Return", "the", "ER7", "-", "encoded", "string" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1126-L1150
crs4/hl7apy
hl7apy/core.py
Component.add_subcomponent
def add_subcomponent(self, name): """ Create an instance of :class:`SubComponent <hl7apy.core.SubComponent>` having the given name :param name: the name of the subcomponent to be created (e.g. CE_1) :return: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c ...
python
def add_subcomponent(self, name): """ Create an instance of :class:`SubComponent <hl7apy.core.SubComponent>` having the given name :param name: the name of the subcomponent to be created (e.g. CE_1) :return: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c ...
[ "def", "add_subcomponent", "(", "self", ",", "name", ")", ":", "if", "self", ".", "is_unknown", "(", ")", "and", "is_base_datatype", "(", "self", ".", "datatype", ")", ":", "# An unknown component can't have a child", "raise", "ChildNotValid", "(", "name", ",", ...
Create an instance of :class:`SubComponent <hl7apy.core.SubComponent>` having the given name :param name: the name of the subcomponent to be created (e.g. CE_1) :return: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c = Component(datatype='CE') >>> ce_1 = c.add_su...
[ "Create", "an", "instance", "of", ":", "class", ":", "SubComponent", "<hl7apy", ".", "core", ".", "SubComponent", ">", "having", "the", "given", "name" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1242-L1259
crs4/hl7apy
hl7apy/core.py
Component.add
def add(self, obj): """ Add an instance of :class:`SubComponent <hl7apy.core.SubComponent>` to the list of children :param obj: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c = Component('CX_10') >>> s = SubComponent(name='CWE_1', value='EXAMPLE_ID') ...
python
def add(self, obj): """ Add an instance of :class:`SubComponent <hl7apy.core.SubComponent>` to the list of children :param obj: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c = Component('CX_10') >>> s = SubComponent(name='CWE_1', value='EXAMPLE_ID') ...
[ "def", "add", "(", "self", ",", "obj", ")", ":", "# base datatype components can't have more than one child", "if", "self", ".", "name", "and", "is_base_datatype", "(", "self", ".", "datatype", ",", "self", ".", "version", ")", "and", "len", "(", "self", ".", ...
Add an instance of :class:`SubComponent <hl7apy.core.SubComponent>` to the list of children :param obj: an instance of :class:`SubComponent <hl7apy.core.SubComponent>` >>> c = Component('CX_10') >>> s = SubComponent(name='CWE_1', value='EXAMPLE_ID') >>> s2 = SubComponent(name='CWE_4', ...
[ "Add", "an", "instance", "of", ":", "class", ":", "SubComponent", "<hl7apy", ".", "core", ".", "SubComponent", ">", "to", "the", "list", "of", "children" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1261-L1291
crs4/hl7apy
hl7apy/core.py
Field.add
def add(self, obj): """ Add an instance of :class:`Component <hl7apy.core.Component>` to the list of children :param obj: an instance of :class:`Component <hl7apy.core.Component>` >>> f = Field('PID_5') >>> f.xpn_1 = 'EVERYMAN' >>> c = Component('XPN_2') >>> c.v...
python
def add(self, obj): """ Add an instance of :class:`Component <hl7apy.core.Component>` to the list of children :param obj: an instance of :class:`Component <hl7apy.core.Component>` >>> f = Field('PID_5') >>> f.xpn_1 = 'EVERYMAN' >>> c = Component('XPN_2') >>> c.v...
[ "def", "add", "(", "self", ",", "obj", ")", ":", "# base datatype components can't have more than one child", "if", "self", ".", "name", "and", "is_base_datatype", "(", "self", ".", "datatype", ",", "self", ".", "version", ")", "and", "len", "(", "self", ".", ...
Add an instance of :class:`Component <hl7apy.core.Component>` to the list of children :param obj: an instance of :class:`Component <hl7apy.core.Component>` >>> f = Field('PID_5') >>> f.xpn_1 = 'EVERYMAN' >>> c = Component('XPN_2') >>> c.value = 'ADAM' >>> f.add(c) ...
[ "Add", "an", "instance", "of", ":", "class", ":", "Component", "<hl7apy", ".", "core", ".", "Component", ">", "to", "the", "list", "of", "children" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1402-L1421
crs4/hl7apy
hl7apy/core.py
Field.to_er7
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding <hl7apy.get_default_...
python
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding <hl7apy.get_default_...
[ "def", "to_er7", "(", "self", ",", "encoding_chars", "=", "None", ",", "trailing_children", "=", "False", ")", ":", "if", "encoding_chars", "is", "None", ":", "encoding_chars", "=", "self", ".", "encoding_chars", "if", "self", ".", "is_named", "(", "'MSH_1'"...
Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding <hl7apy.get_default_encoding_chars>`) :type trailing_children: ``bool`` :param trailing...
[ "Return", "the", "ER7", "-", "encoded", "string" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1433-L1463
crs4/hl7apy
hl7apy/core.py
Field._get_traversal_children
def _get_traversal_children(self, name): """ Retrieve component and subcomponent indexes from the given traversal path (e.g. PID_1_2 -> component=2, subcomponent=None) """ name = name.upper() parts = name.split('_') try: assert 3 <= len(parts) <= 4 ...
python
def _get_traversal_children(self, name): """ Retrieve component and subcomponent indexes from the given traversal path (e.g. PID_1_2 -> component=2, subcomponent=None) """ name = name.upper() parts = name.split('_') try: assert 3 <= len(parts) <= 4 ...
[ "def", "_get_traversal_children", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "parts", "=", "name", ".", "split", "(", "'_'", ")", "try", ":", "assert", "3", "<=", "len", "(", "parts", ")", "<=", "4", "prefix", ...
Retrieve component and subcomponent indexes from the given traversal path (e.g. PID_1_2 -> component=2, subcomponent=None)
[ "Retrieve", "component", "and", "subcomponent", "indexes", "from", "the", "given", "traversal", "path", "(", "e", ".", "g", ".", "PID_1_2", "-", ">", "component", "=", "2", "subcomponent", "=", "None", ")" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1491-L1508
crs4/hl7apy
hl7apy/core.py
Segment.find_child_reference
def find_child_reference(self, name): """ Override the corresponding :class`Element <hl7apy.core.Element>`'s method. This is done for segments that allow children other than the ones expected in the HL7 structure: the ones with the last known field of type `varies` and the Z-Segments. ...
python
def find_child_reference(self, name): """ Override the corresponding :class`Element <hl7apy.core.Element>`'s method. This is done for segments that allow children other than the ones expected in the HL7 structure: the ones with the last known field of type `varies` and the Z-Segments. ...
[ "def", "find_child_reference", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "element", "=", "self", ".", "structure_by_name", ".", "get", "(", "name", ",", "None", ")", "or", "self", ".", "structure_by_longname", ".", ...
Override the corresponding :class`Element <hl7apy.core.Element>`'s method. This is done for segments that allow children other than the ones expected in the HL7 structure: the ones with the last known field of type `varies` and the Z-Segments. The :class:`Field <hl7apy.core.Field>` will be creat...
[ "Override", "the", "corresponding", ":", "class", "Element", "<hl7apy", ".", "core", ".", "Element", ">", "s", "method", ".", "This", "is", "done", "for", "segments", "that", "allow", "children", "other", "than", "the", "ones", "expected", "in", "the", "HL...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1636-L1667
crs4/hl7apy
hl7apy/core.py
Segment.to_er7
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_de...
python
def to_er7(self, encoding_chars=None, trailing_children=False): """ Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_de...
[ "def", "to_er7", "(", "self", ",", "encoding_chars", "=", "None", ",", "trailing_children", "=", "False", ")", ":", "if", "encoding_chars", "is", "None", ":", "encoding_chars", "=", "self", ".", "encoding_chars", "separator", "=", "encoding_chars", ".", "get",...
Return the ER7-encoded string :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_default_encoding_chars>`) :type trailing_children: ``bool`` :param tr...
[ "Return", "the", "ER7", "-", "encoded", "string" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1685-L1722
crs4/hl7apy
hl7apy/core.py
Message.to_mllp
def to_mllp(self, encoding_chars=None, trailing_children=False): """ Returns the er7 representation of the message wrapped with mllp encoding characters :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default ...
python
def to_mllp(self, encoding_chars=None, trailing_children=False): """ Returns the er7 representation of the message wrapped with mllp encoding characters :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default ...
[ "def", "to_mllp", "(", "self", ",", "encoding_chars", "=", "None", ",", "trailing_children", "=", "False", ")", ":", "if", "encoding_chars", "is", "None", ":", "encoding_chars", "=", "self", ".", "encoding_chars", "return", "\"{0}{1}{2}{3}{2}\"", ".", "format", ...
Returns the er7 representation of the message wrapped with mllp encoding characters :type encoding_chars: ``dict`` :param encoding_chars: a dictionary containing the encoding chars or None to use the default (see :func:`get_default_encoding_chars <hl7apy.get_default_encoding_chars>`) ...
[ "Returns", "the", "er7", "representation", "of", "the", "message", "wrapped", "with", "mllp", "encoding", "characters" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L1969-L1988
crs4/hl7apy
hl7apy/validation.py
Validator.validate
def validate(element, reference=None, report_file=None): """ Checks if the :class:`Element <hl7apy.core.Element>` is a valid HL7 message according to the reference specified. If the reference is not specified, it will be used the official HL7 structures for the elements. In parti...
python
def validate(element, reference=None, report_file=None): """ Checks if the :class:`Element <hl7apy.core.Element>` is a valid HL7 message according to the reference specified. If the reference is not specified, it will be used the official HL7 structures for the elements. In parti...
[ "def", "validate", "(", "element", ",", "reference", "=", "None", ",", "report_file", "=", "None", ")", ":", "from", "hl7apy", ".", "core", "import", "is_base_datatype", "def", "_check_z_element", "(", "el", ",", "errs", ",", "warns", ")", ":", "if", "el...
Checks if the :class:`Element <hl7apy.core.Element>` is a valid HL7 message according to the reference specified. If the reference is not specified, it will be used the official HL7 structures for the elements. In particular it checks: * the maximum and minimum number of occurrences for...
[ "Checks", "if", "the", ":", "class", ":", "Element", "<hl7apy", ".", "core", ".", "Element", ">", "is", "a", "valid", "HL7", "message", "according", "to", "the", "reference", "specified", ".", "If", "the", "reference", "is", "not", "specified", "it", "wi...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/validation.py#L40-L210
crs4/hl7apy
hl7apy/parser.py
parse_message
def parse_message(message, validation_level=None, find_groups=True, message_profile=None, report_file=None, force_validation=False): """ Parse the given ER7-encoded message and return an instance of :class:`Message <hl7apy.core.Message>`. :type message: ``str`` :param message: the ER7...
python
def parse_message(message, validation_level=None, find_groups=True, message_profile=None, report_file=None, force_validation=False): """ Parse the given ER7-encoded message and return an instance of :class:`Message <hl7apy.core.Message>`. :type message: ``str`` :param message: the ER7...
[ "def", "parse_message", "(", "message", ",", "validation_level", "=", "None", ",", "find_groups", "=", "True", ",", "message_profile", "=", "None", ",", "report_file", "=", "None", ",", "force_validation", "=", "False", ")", ":", "message", "=", "message", "...
Parse the given ER7-encoded message and return an instance of :class:`Message <hl7apy.core.Message>`. :type message: ``str`` :param message: the ER7-encoded message to be parsed :type validation_level: ``int`` :param validation_level: the validation level. Possible values are those defined in ...
[ "Parse", "the", "given", "ER7", "-", "encoded", "message", "and", "return", "an", "instance", "of", ":", "class", ":", "Message", "<hl7apy", ".", "core", ".", "Message", ">", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L38-L100
crs4/hl7apy
hl7apy/parser.py
parse_segments
def parse_segments(text, version=None, encoding_chars=None, validation_level=None, references=None, find_groups=False): """ Parse the given ER7-encoded segments and return a list of :class:`hl7apy.core.Segment` instances. :type text: ``str`` :param text: the ER7-encoded string containing the segments t...
python
def parse_segments(text, version=None, encoding_chars=None, validation_level=None, references=None, find_groups=False): """ Parse the given ER7-encoded segments and return a list of :class:`hl7apy.core.Segment` instances. :type text: ``str`` :param text: the ER7-encoded string containing the segments t...
[ "def", "parse_segments", "(", "text", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "references", "=", "None", ",", "find_groups", "=", "False", ")", ":", "version", "=", "_get_version", "(", "v...
Parse the given ER7-encoded segments and return a list of :class:`hl7apy.core.Segment` instances. :type text: ``str`` :param text: the ER7-encoded string containing the segments to be parsed :type version: ``str`` :param version: the HL7 version (e.g. "2.5"), or ``None`` to use the default (se...
[ "Parse", "the", "given", "ER7", "-", "encoded", "segments", "and", "return", "a", "list", "of", ":", "class", ":", "hl7apy", ".", "core", ".", "Segment", "instances", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L103-L195
crs4/hl7apy
hl7apy/parser.py
parse_segment
def parse_segment(text, version=None, encoding_chars=None, validation_level=None, reference=None): """ Parse the given ER7-encoded segment and return an instance of :class:`Segment <hl7apy.core.Segment>`. :type text: ``str`` :param text: the ER7-encoded string containing the segment to be parsed :...
python
def parse_segment(text, version=None, encoding_chars=None, validation_level=None, reference=None): """ Parse the given ER7-encoded segment and return an instance of :class:`Segment <hl7apy.core.Segment>`. :type text: ``str`` :param text: the ER7-encoded string containing the segment to be parsed :...
[ "def", "parse_segment", "(", "text", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "reference", "=", "None", ")", ":", "version", "=", "_get_version", "(", "version", ")", "encoding_chars", "=", ...
Parse the given ER7-encoded segment and return an instance of :class:`Segment <hl7apy.core.Segment>`. :type text: ``str`` :param text: the ER7-encoded string containing the segment to be parsed :type version: ``str`` :param version: the HL7 version (e.g. "2.5"), or ``None`` to use the default ...
[ "Parse", "the", "given", "ER7", "-", "encoded", "segment", "and", "return", "an", "instance", "of", ":", "class", ":", "Segment", "<hl7apy", ".", "core", ".", "Segment", ">", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L198-L242
crs4/hl7apy
hl7apy/parser.py
parse_fields
def parse_fields(text, name_prefix=None, version=None, encoding_chars=None, validation_level=None, references=None, force_varies=False): """ Parse the given ER7-encoded fields and return a list of :class:`hl7apy.core.Field`. :type text: ``str`` :param text: the ER7-encoded string conta...
python
def parse_fields(text, name_prefix=None, version=None, encoding_chars=None, validation_level=None, references=None, force_varies=False): """ Parse the given ER7-encoded fields and return a list of :class:`hl7apy.core.Field`. :type text: ``str`` :param text: the ER7-encoded string conta...
[ "def", "parse_fields", "(", "text", ",", "name_prefix", "=", "None", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "references", "=", "None", ",", "force_varies", "=", "False", ")", ":", "versio...
Parse the given ER7-encoded fields and return a list of :class:`hl7apy.core.Field`. :type text: ``str`` :param text: the ER7-encoded string containing the fields to be parsed :type name_prefix: ``str`` :param name_prefix: the field prefix (e.g. MSH) :type version: ``str`` :param version: the ...
[ "Parse", "the", "given", "ER7", "-", "encoded", "fields", "and", "return", "a", "list", "of", ":", "class", ":", "hl7apy", ".", "core", ".", "Field", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L245-L319
crs4/hl7apy
hl7apy/parser.py
parse_field
def parse_field(text, name=None, version=None, encoding_chars=None, validation_level=None, reference=None, force_varies=False): """ Parse the given ER7-encoded field and return an instance of :class:`Field <hl7apy.core.Field>`. :type text: ``str`` :param text: the ER7-encoded string con...
python
def parse_field(text, name=None, version=None, encoding_chars=None, validation_level=None, reference=None, force_varies=False): """ Parse the given ER7-encoded field and return an instance of :class:`Field <hl7apy.core.Field>`. :type text: ``str`` :param text: the ER7-encoded string con...
[ "def", "parse_field", "(", "text", ",", "name", "=", "None", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "reference", "=", "None", ",", "force_varies", "=", "False", ")", ":", "version", "="...
Parse the given ER7-encoded field and return an instance of :class:`Field <hl7apy.core.Field>`. :type text: ``str`` :param text: the ER7-encoded string containing the fields to be parsed :type name: ``str`` :param name: the field name (e.g. MSH_7) :type version: ``str`` :param version: the HL...
[ "Parse", "the", "given", "ER7", "-", "encoded", "field", "and", "return", "an", "instance", "of", ":", "class", ":", "Field", "<hl7apy", ".", "core", ".", "Field", ">", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L322-L394
crs4/hl7apy
hl7apy/parser.py
parse_components
def parse_components(text, field_datatype='ST', version=None, encoding_chars=None, validation_level=None, references=None): """ Parse the given ER7-encoded components and return a list of :class:`Component <hl7apy.core.Component>` instances. :type text: ``str`` :param text: the...
python
def parse_components(text, field_datatype='ST', version=None, encoding_chars=None, validation_level=None, references=None): """ Parse the given ER7-encoded components and return a list of :class:`Component <hl7apy.core.Component>` instances. :type text: ``str`` :param text: the...
[ "def", "parse_components", "(", "text", ",", "field_datatype", "=", "'ST'", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "references", "=", "None", ")", ":", "version", "=", "_get_version", "(", ...
Parse the given ER7-encoded components and return a list of :class:`Component <hl7apy.core.Component>` instances. :type text: ``str`` :param text: the ER7-encoded string containing the components to be parsed :type field_datatype: ``str`` :param field_datatype: the datatype of the components (e.g....
[ "Parse", "the", "given", "ER7", "-", "encoded", "components", "and", "return", "a", "list", "of", ":", "class", ":", "Component", "<hl7apy", ".", "core", ".", "Component", ">", "instances", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L397-L463
crs4/hl7apy
hl7apy/parser.py
parse_component
def parse_component(text, name=None, datatype='ST', version=None, encoding_chars=None, validation_level=None, reference=None): """ Parse the given ER7-encoded component and return an instance of :class:`Component <hl7apy.core.Component>`. :type text: ``str`` :param text: the ER7...
python
def parse_component(text, name=None, datatype='ST', version=None, encoding_chars=None, validation_level=None, reference=None): """ Parse the given ER7-encoded component and return an instance of :class:`Component <hl7apy.core.Component>`. :type text: ``str`` :param text: the ER7...
[ "def", "parse_component", "(", "text", ",", "name", "=", "None", ",", "datatype", "=", "'ST'", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ",", "reference", "=", "None", ")", ":", "version", "=",...
Parse the given ER7-encoded component and return an instance of :class:`Component <hl7apy.core.Component>`. :type text: ``str`` :param text: the ER7-encoded string containing the components to be parsed :type name: ``str`` :param name: the component's name (e.g. XPN_2) :type datatype: ``str``...
[ "Parse", "the", "given", "ER7", "-", "encoded", "component", "and", "return", "an", "instance", "of", ":", "class", ":", "Component", "<hl7apy", ".", "core", ".", "Component", ">", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L466-L527
crs4/hl7apy
hl7apy/parser.py
parse_subcomponents
def parse_subcomponents(text, component_datatype='ST', version=None, encoding_chars=None, validation_level=None): """ Parse the given ER7-encoded subcomponents and return a list of :class:`SubComponent <hl7apy.core.SubComponent>` instances. :type text: ``str`` :param text: t...
python
def parse_subcomponents(text, component_datatype='ST', version=None, encoding_chars=None, validation_level=None): """ Parse the given ER7-encoded subcomponents and return a list of :class:`SubComponent <hl7apy.core.SubComponent>` instances. :type text: ``str`` :param text: t...
[ "def", "parse_subcomponents", "(", "text", ",", "component_datatype", "=", "'ST'", ",", "version", "=", "None", ",", "encoding_chars", "=", "None", ",", "validation_level", "=", "None", ")", ":", "version", "=", "_get_version", "(", "version", ")", "encoding_c...
Parse the given ER7-encoded subcomponents and return a list of :class:`SubComponent <hl7apy.core.SubComponent>` instances. :type text: ``str`` :param text: the ER7-encoded string containing the components to be parsed :type component_datatype: ``str`` :param component_datatype: the datatype of the...
[ "Parse", "the", "given", "ER7", "-", "encoded", "subcomponents", "and", "return", "a", "list", "of", ":", "class", ":", "SubComponent", "<hl7apy", ".", "core", ".", "SubComponent", ">", "instances", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L530-L588
crs4/hl7apy
hl7apy/parser.py
parse_subcomponent
def parse_subcomponent(text, name=None, datatype='ST', version=None, validation_level=None): """ Parse the given ER7-encoded component and return an instance of :class:`SubComponent <hl7apy.core.SubComponent>`. :type text: ``str`` :param text: the ER7-encoded string containing the subcomponent data...
python
def parse_subcomponent(text, name=None, datatype='ST', version=None, validation_level=None): """ Parse the given ER7-encoded component and return an instance of :class:`SubComponent <hl7apy.core.SubComponent>`. :type text: ``str`` :param text: the ER7-encoded string containing the subcomponent data...
[ "def", "parse_subcomponent", "(", "text", ",", "name", "=", "None", ",", "datatype", "=", "'ST'", ",", "version", "=", "None", ",", "validation_level", "=", "None", ")", ":", "version", "=", "_get_version", "(", "version", ")", "validation_level", "=", "_g...
Parse the given ER7-encoded component and return an instance of :class:`SubComponent <hl7apy.core.SubComponent>`. :type text: ``str`` :param text: the ER7-encoded string containing the subcomponent data :type name: ``str`` :param name: the subcomponent's name (e.g. XPN_2) :type datatype: ``st...
[ "Parse", "the", "given", "ER7", "-", "encoded", "component", "and", "return", "an", "instance", "of", ":", "class", ":", "SubComponent", "<hl7apy", ".", "core", ".", "SubComponent", ">", "." ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L591-L620
crs4/hl7apy
hl7apy/factories.py
datatype_factory
def datatype_factory(datatype, value, version=None, validation_level=None): """ Factory function for both base and complex datatypes. It generates the correct object according to the datatype in input. It should be noted that if you use the factory it is not possible to specify some parameters for t...
python
def datatype_factory(datatype, value, version=None, validation_level=None): """ Factory function for both base and complex datatypes. It generates the correct object according to the datatype in input. It should be noted that if you use the factory it is not possible to specify some parameters for t...
[ "def", "datatype_factory", "(", "datatype", ",", "value", ",", "version", "=", "None", ",", "validation_level", "=", "None", ")", ":", "from", "hl7apy", ".", "validation", "import", "Validator", "if", "validation_level", "is", "None", ":", "validation_level", ...
Factory function for both base and complex datatypes. It generates the correct object according to the datatype in input. It should be noted that if you use the factory it is not possible to specify some parameters for the datatype (e.g. the format for datetime base datatypes) If the value is not valid ...
[ "Factory", "function", "for", "both", "base", "and", "complex", "datatypes", ".", "It", "generates", "the", "correct", "object", "according", "to", "the", "datatype", "in", "input", ".", "It", "should", "be", "noted", "that", "if", "you", "use", "the", "fa...
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L36-L105
crs4/hl7apy
hl7apy/factories.py
date_factory
def date_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`DT <hl7apy.base_datatypes.DT>` object The value in input must be a string parsable with :meth:`datetime.strptime`. The date format is chosen according to the length of the value as stated in this table: +-------+--...
python
def date_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`DT <hl7apy.base_datatypes.DT>` object The value in input must be a string parsable with :meth:`datetime.strptime`. The date format is chosen according to the length of the value as stated in this table: +-------+--...
[ "def", "date_factory", "(", "value", ",", "datatype_cls", ",", "validation_level", "=", "None", ")", ":", "dt_value", ",", "fmt", "=", "get_date_info", "(", "value", ")", "return", "datatype_cls", "(", "dt_value", ",", "fmt", ")" ]
Creates a :class:`DT <hl7apy.base_datatypes.DT>` object The value in input must be a string parsable with :meth:`datetime.strptime`. The date format is chosen according to the length of the value as stated in this table: +-------+-----------+ |Length |Format | +=======+===========+ |4 ...
[ "Creates", "a", ":", "class", ":", "DT", "<hl7apy", ".", "base_datatypes", ".", "DT", ">", "object" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L108-L155
crs4/hl7apy
hl7apy/factories.py
timestamp_factory
def timestamp_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`TM <hl7apy.base_datatypes.TM>` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +/-HHMM. The offset can be added with...
python
def timestamp_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`TM <hl7apy.base_datatypes.TM>` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +/-HHMM. The offset can be added with...
[ "def", "timestamp_factory", "(", "value", ",", "datatype_cls", ",", "validation_level", "=", "None", ")", ":", "dt_value", ",", "fmt", ",", "offset", ",", "microsec", "=", "get_timestamp_info", "(", "value", ")", "return", "datatype_cls", "(", "dt_value", ",",...
Creates a :class:`TM <hl7apy.base_datatypes.TM>` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +/-HHMM. The offset can be added with all the allowed format The date format is chosen according to the length o...
[ "Creates", "a", ":", "class", ":", "TM", "<hl7apy", ".", "base_datatypes", ".", "TM", ">", "object" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L158-L211
crs4/hl7apy
hl7apy/factories.py
datetime_factory
def datetime_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`hl7apy.base_datatypes.DTM` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +HHMM -HHMM. The offset can be added with ...
python
def datetime_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`hl7apy.base_datatypes.DTM` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +HHMM -HHMM. The offset can be added with ...
[ "def", "datetime_factory", "(", "value", ",", "datatype_cls", ",", "validation_level", "=", "None", ")", ":", "dt_value", ",", "fmt", ",", "offset", ",", "microsec", "=", "get_datetime_info", "(", "value", ")", "return", "datatype_cls", "(", "dt_value", ",", ...
Creates a :class:`hl7apy.base_datatypes.DTM` object The value in input must be a string parsable with :meth:`datetime.strptime`. It can also have an offset part specified with the format +HHMM -HHMM. The offset can be added with all the allowed format. The date format is chosen according to the length ...
[ "Creates", "a", ":", "class", ":", "hl7apy", ".", "base_datatypes", ".", "DTM", "object" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L214-L271
crs4/hl7apy
hl7apy/factories.py
numeric_factory
def numeric_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`NM <hl7apy.base_datatypes.NM>` object The value in input can be a string representing a decimal number or a ``float``. (i.e. a string valid for :class:`decimal.Decimal()`). If it's not, a :exc:`ValueError` is rai...
python
def numeric_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`NM <hl7apy.base_datatypes.NM>` object The value in input can be a string representing a decimal number or a ``float``. (i.e. a string valid for :class:`decimal.Decimal()`). If it's not, a :exc:`ValueError` is rai...
[ "def", "numeric_factory", "(", "value", ",", "datatype_cls", ",", "validation_level", "=", "None", ")", ":", "if", "not", "value", ":", "return", "datatype_cls", "(", "validation_level", "=", "validation_level", ")", "try", ":", "return", "datatype_cls", "(", ...
Creates a :class:`NM <hl7apy.base_datatypes.NM>` object The value in input can be a string representing a decimal number or a ``float``. (i.e. a string valid for :class:`decimal.Decimal()`). If it's not, a :exc:`ValueError` is raised Also an empty string or ``None`` are allowed :type value: ``str`...
[ "Creates", "a", ":", "class", ":", "NM", "<hl7apy", ".", "base_datatypes", ".", "NM", ">", "object" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L274-L301
crs4/hl7apy
hl7apy/factories.py
sequence_id_factory
def sequence_id_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`SI <hl7apy.base_datatypes.SI>` object The value in input can be a string representing an integer number or an ``int``. (i.e. a string valid for ``int()`` ). If it's not, a :exc:`ValueError` is raised Als...
python
def sequence_id_factory(value, datatype_cls, validation_level=None): """ Creates a :class:`SI <hl7apy.base_datatypes.SI>` object The value in input can be a string representing an integer number or an ``int``. (i.e. a string valid for ``int()`` ). If it's not, a :exc:`ValueError` is raised Als...
[ "def", "sequence_id_factory", "(", "value", ",", "datatype_cls", ",", "validation_level", "=", "None", ")", ":", "if", "not", "value", ":", "return", "datatype_cls", "(", "validation_level", "=", "validation_level", ")", "try", ":", "return", "datatype_cls", "("...
Creates a :class:`SI <hl7apy.base_datatypes.SI>` object The value in input can be a string representing an integer number or an ``int``. (i.e. a string valid for ``int()`` ). If it's not, a :exc:`ValueError` is raised Also an empty string or ``None`` are allowed :type value: ``str`` or ``None`` ...
[ "Creates", "a", ":", "class", ":", "SI", "<hl7apy", ".", "base_datatypes", ".", "SI", ">", "object" ]
train
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/factories.py#L304-L331
playpauseandstop/Flask-And-Redis
flask_redis.py
Redis.get_app
def get_app(self): """Get current app from Flast stack to use. This will allow to ensure which Redis connection to be used when accessing Redis connection public methods via plugin. """ # First see to connection stack ctx = connection_stack.top if ctx is not None...
python
def get_app(self): """Get current app from Flast stack to use. This will allow to ensure which Redis connection to be used when accessing Redis connection public methods via plugin. """ # First see to connection stack ctx = connection_stack.top if ctx is not None...
[ "def", "get_app", "(", "self", ")", ":", "# First see to connection stack", "ctx", "=", "connection_stack", ".", "top", "if", "ctx", "is", "not", "None", ":", "return", "ctx", ".", "app", "# Next return app from instance cache", "if", "self", ".", "app", "is", ...
Get current app from Flast stack to use. This will allow to ensure which Redis connection to be used when accessing Redis connection public methods via plugin.
[ "Get", "current", "app", "from", "Flast", "stack", "to", "use", "." ]
train
https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L79-L98
playpauseandstop/Flask-And-Redis
flask_redis.py
Redis.init_app
def init_app(self, app, config_prefix=None): """ Actual method to read redis settings from app configuration, initialize Redis connection and copy all public connection methods to current instance. :param app: :class:`flask.Flask` application instance. :param config_pref...
python
def init_app(self, app, config_prefix=None): """ Actual method to read redis settings from app configuration, initialize Redis connection and copy all public connection methods to current instance. :param app: :class:`flask.Flask` application instance. :param config_pref...
[ "def", "init_app", "(", "self", ",", "app", ",", "config_prefix", "=", "None", ")", ":", "# Put redis to application extensions", "if", "'redis'", "not", "in", "app", ".", "extensions", ":", "app", ".", "extensions", "[", "'redis'", "]", "=", "{", "}", "# ...
Actual method to read redis settings from app configuration, initialize Redis connection and copy all public connection methods to current instance. :param app: :class:`flask.Flask` application instance. :param config_prefix: Config prefix to use. By default: ``REDIS``
[ "Actual", "method", "to", "read", "redis", "settings", "from", "app", "configuration", "initialize", "Redis", "connection", "and", "copy", "all", "public", "connection", "methods", "to", "current", "instance", "." ]
train
https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L100-L170
playpauseandstop/Flask-And-Redis
flask_redis.py
Redis._build_connection_args
def _build_connection_args(self, klass): """Read connection args spec, exclude self from list of possible :param klass: Redis connection class. """ bases = [base for base in klass.__bases__ if base is not object] all_args = [] for cls in [klass] + bases: try:...
python
def _build_connection_args(self, klass): """Read connection args spec, exclude self from list of possible :param klass: Redis connection class. """ bases = [base for base in klass.__bases__ if base is not object] all_args = [] for cls in [klass] + bases: try:...
[ "def", "_build_connection_args", "(", "self", ",", "klass", ")", ":", "bases", "=", "[", "base", "for", "base", "in", "klass", ".", "__bases__", "if", "base", "is", "not", "object", "]", "all_args", "=", "[", "]", "for", "cls", "in", "[", "klass", "]...
Read connection args spec, exclude self from list of possible :param klass: Redis connection class.
[ "Read", "connection", "args", "spec", "exclude", "self", "from", "list", "of", "possible" ]
train
https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L172-L189
playpauseandstop/Flask-And-Redis
flask_redis.py
Redis._include_public_methods
def _include_public_methods(self, connection): """Include public methods from Redis connection to current instance. :param connection: Redis connection instance. """ for attr in dir(connection): value = getattr(connection, attr) if attr.startswith('_') or not cal...
python
def _include_public_methods(self, connection): """Include public methods from Redis connection to current instance. :param connection: Redis connection instance. """ for attr in dir(connection): value = getattr(connection, attr) if attr.startswith('_') or not cal...
[ "def", "_include_public_methods", "(", "self", ",", "connection", ")", ":", "for", "attr", "in", "dir", "(", "connection", ")", ":", "value", "=", "getattr", "(", "connection", ",", "attr", ")", "if", "attr", ".", "startswith", "(", "'_'", ")", "or", "...
Include public methods from Redis connection to current instance. :param connection: Redis connection instance.
[ "Include", "public", "methods", "from", "Redis", "connection", "to", "current", "instance", "." ]
train
https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L191-L200
playpauseandstop/Flask-And-Redis
flask_redis.py
Redis._wrap_public_method
def _wrap_public_method(self, attr): """ Ensure that plugin will call current connection method when accessing as ``plugin.<public_method>(*args, **kwargs)``. """ def wrapper(*args, **kwargs): return getattr(self.connection, attr)(*args, **kwargs) return wrapp...
python
def _wrap_public_method(self, attr): """ Ensure that plugin will call current connection method when accessing as ``plugin.<public_method>(*args, **kwargs)``. """ def wrapper(*args, **kwargs): return getattr(self.connection, attr)(*args, **kwargs) return wrapp...
[ "def", "_wrap_public_method", "(", "self", ",", "attr", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "self", ".", "connection", ",", "attr", ")", "(", "*", "args", ",", "*", "*", "kwargs...
Ensure that plugin will call current connection method when accessing as ``plugin.<public_method>(*args, **kwargs)``.
[ "Ensure", "that", "plugin", "will", "call", "current", "connection", "method", "when", "accessing", "as", "plugin", ".", "<public_method", ">", "(", "*", "args", "**", "kwargs", ")", "." ]
train
https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L202-L209
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.prepare
def prepare(self): '''Prepare to run the docker command''' self.__make_scubadir() if self.is_remote_docker: ''' Docker is running remotely (e.g. boot2docker on OSX). We don't need to do any user setup whatsoever. TODO: For now, remote instances w...
python
def prepare(self): '''Prepare to run the docker command''' self.__make_scubadir() if self.is_remote_docker: ''' Docker is running remotely (e.g. boot2docker on OSX). We don't need to do any user setup whatsoever. TODO: For now, remote instances w...
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "__make_scubadir", "(", ")", "if", "self", ".", "is_remote_docker", ":", "'''\n Docker is running remotely (e.g. boot2docker on OSX).\n We don't need to do any user setup whatsoever.\n\n TODO: For ...
Prepare to run the docker command
[ "Prepare", "to", "run", "the", "docker", "command" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L119-L139
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.add_env
def add_env(self, name, val): '''Add an environment variable to the docker run invocation ''' if name in self.env_vars: raise KeyError(name) self.env_vars[name] = val
python
def add_env(self, name, val): '''Add an environment variable to the docker run invocation ''' if name in self.env_vars: raise KeyError(name) self.env_vars[name] = val
[ "def", "add_env", "(", "self", ",", "name", ",", "val", ")", ":", "if", "name", "in", "self", ".", "env_vars", ":", "raise", "KeyError", "(", "name", ")", "self", ".", "env_vars", "[", "name", "]", "=", "val" ]
Add an environment variable to the docker run invocation
[ "Add", "an", "environment", "variable", "to", "the", "docker", "run", "invocation" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L176-L181
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.add_volume
def add_volume(self, hostpath, contpath, options=None): '''Add a volume (bind-mount) to the docker run invocation ''' if options is None: options = [] self.volumes.append((hostpath, contpath, options))
python
def add_volume(self, hostpath, contpath, options=None): '''Add a volume (bind-mount) to the docker run invocation ''' if options is None: options = [] self.volumes.append((hostpath, contpath, options))
[ "def", "add_volume", "(", "self", ",", "hostpath", ",", "contpath", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "[", "]", "self", ".", "volumes", ".", "append", "(", "(", "hostpath", ",", "contpath", ","...
Add a volume (bind-mount) to the docker run invocation
[ "Add", "a", "volume", "(", "bind", "-", "mount", ")", "to", "the", "docker", "run", "invocation" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L183-L188
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.__locate_scubainit
def __locate_scubainit(self): '''Determine path to scubainit binary ''' pkg_path = os.path.dirname(__file__) self.scubainit_path = os.path.join(pkg_path, 'scubainit') if not os.path.isfile(self.scubainit_path): raise ScubaError('scubainit not found at "{}"'.format(se...
python
def __locate_scubainit(self): '''Determine path to scubainit binary ''' pkg_path = os.path.dirname(__file__) self.scubainit_path = os.path.join(pkg_path, 'scubainit') if not os.path.isfile(self.scubainit_path): raise ScubaError('scubainit not found at "{}"'.format(se...
[ "def", "__locate_scubainit", "(", "self", ")", ":", "pkg_path", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "self", ".", "scubainit_path", "=", "os", ".", "path", ".", "join", "(", "pkg_path", ",", "'scubainit'", ")", "if", "not", "os...
Determine path to scubainit binary
[ "Determine", "path", "to", "scubainit", "binary" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L198-L205
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.__load_config
def __load_config(self): '''Find and load .scuba.yml ''' # top_path is where .scuba.yml is found, and becomes the top of our bind mount. # top_rel is the relative path from top_path to the current working directory, # and is where we'll set the working directory in the container...
python
def __load_config(self): '''Find and load .scuba.yml ''' # top_path is where .scuba.yml is found, and becomes the top of our bind mount. # top_rel is the relative path from top_path to the current working directory, # and is where we'll set the working directory in the container...
[ "def", "__load_config", "(", "self", ")", ":", "# top_path is where .scuba.yml is found, and becomes the top of our bind mount.", "# top_rel is the relative path from top_path to the current working directory,", "# and is where we'll set the working directory in the container (relative to", "# the...
Find and load .scuba.yml
[ "Find", "and", "load", ".", "scuba", ".", "yml" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L208-L235
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.__make_scubadir
def __make_scubadir(self): '''Make temp directory where all ancillary files are bind-mounted ''' self.__scubadir_hostpath = tempfile.mkdtemp(prefix='scubadir') self.__scubadir_contpath = '/.scuba' self.add_volume(self.__scubadir_hostpath, self.__scubadir_contpath)
python
def __make_scubadir(self): '''Make temp directory where all ancillary files are bind-mounted ''' self.__scubadir_hostpath = tempfile.mkdtemp(prefix='scubadir') self.__scubadir_contpath = '/.scuba' self.add_volume(self.__scubadir_hostpath, self.__scubadir_contpath)
[ "def", "__make_scubadir", "(", "self", ")", ":", "self", ".", "__scubadir_hostpath", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'scubadir'", ")", "self", ".", "__scubadir_contpath", "=", "'/.scuba'", "self", ".", "add_volume", "(", "self", ".", "_...
Make temp directory where all ancillary files are bind-mounted
[ "Make", "temp", "directory", "where", "all", "ancillary", "files", "are", "bind", "-", "mounted" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L237-L242
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.__setup_native_run
def __setup_native_run(self): # These options are appended to mounted volume arguments # NOTE: This tells Docker to re-label the directory for compatibility # with SELinux. See `man docker-run` for more information. self.vol_opts = ['z'] # Pass variables to scubainit se...
python
def __setup_native_run(self): # These options are appended to mounted volume arguments # NOTE: This tells Docker to re-label the directory for compatibility # with SELinux. See `man docker-run` for more information. self.vol_opts = ['z'] # Pass variables to scubainit se...
[ "def", "__setup_native_run", "(", "self", ")", ":", "# These options are appended to mounted volume arguments", "# NOTE: This tells Docker to re-label the directory for compatibility", "# with SELinux. See `man docker-run` for more information.", "self", ".", "vol_opts", "=", "[", "'z'",...
Normally, if the user provides no command to "docker run", the image's default CMD is run. Because we set the entrypiont, scuba must emulate the default behavior itself.
[ "Normally", "if", "the", "user", "provides", "no", "command", "to", "docker", "run", "the", "image", "s", "default", "CMD", "is", "run", ".", "Because", "we", "set", "the", "entrypiont", "scuba", "must", "emulate", "the", "default", "behavior", "itself", "...
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L244-L326
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.open_scubadir_file
def open_scubadir_file(self, name, mode): '''Opens a file in the 'scubadir' This file will automatically be bind-mounted into the container, at a path given by the 'container_path' property on the returned file object. ''' path = os.path.join(self.__scubadir_hostpath, name) ...
python
def open_scubadir_file(self, name, mode): '''Opens a file in the 'scubadir' This file will automatically be bind-mounted into the container, at a path given by the 'container_path' property on the returned file object. ''' path = os.path.join(self.__scubadir_hostpath, name) ...
[ "def", "open_scubadir_file", "(", "self", ",", "name", ",", "mode", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "__scubadir_hostpath", ",", "name", ")", "assert", "not", "os", ".", "path", ".", "exists", "(", "path", ")",...
Opens a file in the 'scubadir' This file will automatically be bind-mounted into the container, at a path given by the 'container_path' property on the returned file object.
[ "Opens", "a", "file", "in", "the", "scubadir" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L330-L344
JonathonReinhart/scuba
scuba/__main__.py
ScubaDive.copy_scubadir_file
def copy_scubadir_file(self, name, source): '''Copies source into the scubadir Returns the container-path of the copied file ''' dest = os.path.join(self.__scubadir_hostpath, name) assert not os.path.exists(dest) shutil.copy2(source, dest) return os.path.join(se...
python
def copy_scubadir_file(self, name, source): '''Copies source into the scubadir Returns the container-path of the copied file ''' dest = os.path.join(self.__scubadir_hostpath, name) assert not os.path.exists(dest) shutil.copy2(source, dest) return os.path.join(se...
[ "def", "copy_scubadir_file", "(", "self", ",", "name", ",", "source", ")", ":", "dest", "=", "os", ".", "path", ".", "join", "(", "self", ".", "__scubadir_hostpath", ",", "name", ")", "assert", "not", "os", ".", "path", ".", "exists", "(", "dest", ")...
Copies source into the scubadir Returns the container-path of the copied file
[ "Copies", "source", "into", "the", "scubadir" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L347-L356
JonathonReinhart/scuba
scuba/utils.py
format_cmdline
def format_cmdline(args, maxwidth=80): '''Format args into a shell-quoted command line. The result will be wrapped to maxwidth characters where possible, not breaking a single long argument. ''' # Leave room for the space and backslash at the end of each line maxwidth -= 2 def lines(): ...
python
def format_cmdline(args, maxwidth=80): '''Format args into a shell-quoted command line. The result will be wrapped to maxwidth characters where possible, not breaking a single long argument. ''' # Leave room for the space and backslash at the end of each line maxwidth -= 2 def lines(): ...
[ "def", "format_cmdline", "(", "args", ",", "maxwidth", "=", "80", ")", ":", "# Leave room for the space and backslash at the end of each line", "maxwidth", "-=", "2", "def", "lines", "(", ")", ":", "line", "=", "''", "for", "a", "in", "(", "shell_quote", "(", ...
Format args into a shell-quoted command line. The result will be wrapped to maxwidth characters where possible, not breaking a single long argument.
[ "Format", "args", "into", "a", "shell", "-", "quoted", "command", "line", "." ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/utils.py#L13-L41
JonathonReinhart/scuba
scuba/utils.py
parse_env_var
def parse_env_var(s): """Parse an environment variable string Returns a key-value tuple Apply the same logic as `docker run -e`: "If the operator names an environment variable without specifying a value, then the current value of the named variable is propagated into the container's environmen...
python
def parse_env_var(s): """Parse an environment variable string Returns a key-value tuple Apply the same logic as `docker run -e`: "If the operator names an environment variable without specifying a value, then the current value of the named variable is propagated into the container's environmen...
[ "def", "parse_env_var", "(", "s", ")", ":", "parts", "=", "s", ".", "split", "(", "'='", ",", "1", ")", "if", "len", "(", "parts", ")", "==", "2", ":", "k", ",", "v", "=", "parts", "return", "(", "k", ",", "v", ")", "k", "=", "parts", "[", ...
Parse an environment variable string Returns a key-value tuple Apply the same logic as `docker run -e`: "If the operator names an environment variable without specifying a value, then the current value of the named variable is propagated into the container's environment
[ "Parse", "an", "environment", "variable", "string" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/utils.py#L53-L69
JonathonReinhart/scuba
scuba/dockerutil.py
__wrap_docker_exec
def __wrap_docker_exec(func): '''Wrap a function to raise DockerExecuteError on ENOENT''' def call(*args, **kwargs): try: return func(*args, **kwargs) except OSError as e: if e.errno == errno.ENOENT: raise DockerExecuteError('Failed to execute docker. Is i...
python
def __wrap_docker_exec(func): '''Wrap a function to raise DockerExecuteError on ENOENT''' def call(*args, **kwargs): try: return func(*args, **kwargs) except OSError as e: if e.errno == errno.ENOENT: raise DockerExecuteError('Failed to execute docker. Is i...
[ "def", "__wrap_docker_exec", "(", "func", ")", ":", "def", "call", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "OSError", "as", "e", ":", "if", "e", ...
Wrap a function to raise DockerExecuteError on ENOENT
[ "Wrap", "a", "function", "to", "raise", "DockerExecuteError", "on", "ENOENT" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L19-L28
JonathonReinhart/scuba
scuba/dockerutil.py
docker_inspect
def docker_inspect(image): '''Inspects a docker image Returns: Parsed JSON data ''' args = ['docker', 'inspect', '--type', 'image', image] p = Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) stdout, stderr = p.communicate() stdout = stdout.decode('utf-8') stderr = stder...
python
def docker_inspect(image): '''Inspects a docker image Returns: Parsed JSON data ''' args = ['docker', 'inspect', '--type', 'image', image] p = Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) stdout, stderr = p.communicate() stdout = stdout.decode('utf-8') stderr = stder...
[ "def", "docker_inspect", "(", "image", ")", ":", "args", "=", "[", "'docker'", ",", "'inspect'", ",", "'--type'", ",", "'image'", ",", "image", "]", "p", "=", "Popen", "(", "args", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "s...
Inspects a docker image Returns: Parsed JSON data
[ "Inspects", "a", "docker", "image" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L34-L51
JonathonReinhart/scuba
scuba/dockerutil.py
docker_pull
def docker_pull(image): '''Pulls an image''' args = ['docker', 'pull', image] # If this fails, the default docker stdout/stderr looks good to the user. ret = call(args) if ret != 0: raise DockerError('Failed to pull image "{}"'.format(image))
python
def docker_pull(image): '''Pulls an image''' args = ['docker', 'pull', image] # If this fails, the default docker stdout/stderr looks good to the user. ret = call(args) if ret != 0: raise DockerError('Failed to pull image "{}"'.format(image))
[ "def", "docker_pull", "(", "image", ")", ":", "args", "=", "[", "'docker'", ",", "'pull'", ",", "image", "]", "# If this fails, the default docker stdout/stderr looks good to the user.", "ret", "=", "call", "(", "args", ")", "if", "ret", "!=", "0", ":", "raise",...
Pulls an image
[ "Pulls", "an", "image" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L53-L60
JonathonReinhart/scuba
scuba/dockerutil.py
get_image_command
def get_image_command(image): '''Gets the default command for an image''' info = docker_inspect_or_pull(image) try: return info['Config']['Cmd'] except KeyError as ke: raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))
python
def get_image_command(image): '''Gets the default command for an image''' info = docker_inspect_or_pull(image) try: return info['Config']['Cmd'] except KeyError as ke: raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))
[ "def", "get_image_command", "(", "image", ")", ":", "info", "=", "docker_inspect_or_pull", "(", "image", ")", "try", ":", "return", "info", "[", "'Config'", "]", "[", "'Cmd'", "]", "except", "KeyError", "as", "ke", ":", "raise", "DockerError", "(", "'Faile...
Gets the default command for an image
[ "Gets", "the", "default", "command", "for", "an", "image" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L71-L77
JonathonReinhart/scuba
scuba/dockerutil.py
get_image_entrypoint
def get_image_entrypoint(image): '''Gets the image entrypoint''' info = docker_inspect_or_pull(image) try: return info['Config']['Entrypoint'] except KeyError as ke: raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))
python
def get_image_entrypoint(image): '''Gets the image entrypoint''' info = docker_inspect_or_pull(image) try: return info['Config']['Entrypoint'] except KeyError as ke: raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))
[ "def", "get_image_entrypoint", "(", "image", ")", ":", "info", "=", "docker_inspect_or_pull", "(", "image", ")", "try", ":", "return", "info", "[", "'Config'", "]", "[", "'Entrypoint'", "]", "except", "KeyError", "as", "ke", ":", "raise", "DockerError", "(",...
Gets the image entrypoint
[ "Gets", "the", "image", "entrypoint" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L79-L85
JonathonReinhart/scuba
scuba/dockerutil.py
make_vol_opt
def make_vol_opt(hostdir, contdir, options=None): '''Generate a docker volume option''' vol = '--volume={}:{}'.format(hostdir, contdir) if options != None: if isinstance(options, str): options = (options,) vol += ':' + ','.join(options) return vol
python
def make_vol_opt(hostdir, contdir, options=None): '''Generate a docker volume option''' vol = '--volume={}:{}'.format(hostdir, contdir) if options != None: if isinstance(options, str): options = (options,) vol += ':' + ','.join(options) return vol
[ "def", "make_vol_opt", "(", "hostdir", ",", "contdir", ",", "options", "=", "None", ")", ":", "vol", "=", "'--volume={}:{}'", ".", "format", "(", "hostdir", ",", "contdir", ")", "if", "options", "!=", "None", ":", "if", "isinstance", "(", "options", ",",...
Generate a docker volume option
[ "Generate", "a", "docker", "volume", "option" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/dockerutil.py#L88-L95
JonathonReinhart/scuba
scuba/config.py
find_config
def find_config(): '''Search up the diretcory hierarchy for .scuba.yml Returns: path, rel on success, or None if not found path The absolute path of the directory where .scuba.yml was found rel The relative path from the directory where .scuba.yml was found to the current...
python
def find_config(): '''Search up the diretcory hierarchy for .scuba.yml Returns: path, rel on success, or None if not found path The absolute path of the directory where .scuba.yml was found rel The relative path from the directory where .scuba.yml was found to the current...
[ "def", "find_config", "(", ")", ":", "cross_fs", "=", "'SCUBA_DISCOVERY_ACROSS_FILESYSTEM'", "in", "os", ".", "environ", "path", "=", "os", ".", "getcwd", "(", ")", "rel", "=", "''", "while", "True", ":", "if", "os", ".", "path", ".", "exists", "(", "o...
Search up the diretcory hierarchy for .scuba.yml Returns: path, rel on success, or None if not found path The absolute path of the directory where .scuba.yml was found rel The relative path from the directory where .scuba.yml was found to the current directory
[ "Search", "up", "the", "diretcory", "hierarchy", "for", ".", "scuba", ".", "yml" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L74-L101
JonathonReinhart/scuba
scuba/config.py
_process_script_node
def _process_script_node(node, name): '''Process a script-type node This handles nodes that follow the *Common script schema*, as outlined in doc/yaml-reference.md. ''' if isinstance(node, basestring): # The script is just the text itself return [node] if isinstance(node, dict...
python
def _process_script_node(node, name): '''Process a script-type node This handles nodes that follow the *Common script schema*, as outlined in doc/yaml-reference.md. ''' if isinstance(node, basestring): # The script is just the text itself return [node] if isinstance(node, dict...
[ "def", "_process_script_node", "(", "node", ",", "name", ")", ":", "if", "isinstance", "(", "node", ",", "basestring", ")", ":", "# The script is just the text itself", "return", "[", "node", "]", "if", "isinstance", "(", "node", ",", "dict", ")", ":", "# Th...
Process a script-type node This handles nodes that follow the *Common script schema*, as outlined in doc/yaml-reference.md.
[ "Process", "a", "script", "-", "type", "node" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L104-L129
JonathonReinhart/scuba
scuba/config.py
Loader.from_yaml
def from_yaml(self, node): ''' Implementes a !from_yaml constructor with the following syntax: !from_yaml filename key Arguments: filename: Filename of external YAML document from which to load, relative to the current YAML file. key...
python
def from_yaml(self, node): ''' Implementes a !from_yaml constructor with the following syntax: !from_yaml filename key Arguments: filename: Filename of external YAML document from which to load, relative to the current YAML file. key...
[ "def", "from_yaml", "(", "self", ",", "node", ")", ":", "# Load the content from the node, as a scalar", "content", "=", "self", ".", "construct_scalar", "(", "node", ")", "# Split on unquoted spaces", "try", ":", "parts", "=", "shlex", ".", "split", "(", "content...
Implementes a !from_yaml constructor with the following syntax: !from_yaml filename key Arguments: filename: Filename of external YAML document from which to load, relative to the current YAML file. key: Key from external YAML document to ret...
[ "Implementes", "a", "!from_yaml", "constructor", "with", "the", "following", "syntax", ":", "!from_yaml", "filename", "key" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L25-L69
JonathonReinhart/scuba
scuba/config.py
ScubaConfig.process_command
def process_command(self, command): '''Processes a user command using aliases Arguments: command A user command list (e.g. argv) Returns: A ScubaContext object with the following attributes: script: a list of command line strings image: the docker image ...
python
def process_command(self, command): '''Processes a user command using aliases Arguments: command A user command list (e.g. argv) Returns: A ScubaContext object with the following attributes: script: a list of command line strings image: the docker image ...
[ "def", "process_command", "(", "self", ",", "command", ")", ":", "result", "=", "ScubaContext", "(", ")", "result", ".", "script", "=", "None", "result", ".", "image", "=", "self", ".", "image", "result", ".", "entrypoint", "=", "self", ".", "entrypoint"...
Processes a user command using aliases Arguments: command A user command list (e.g. argv) Returns: A ScubaContext object with the following attributes: script: a list of command line strings image: the docker image name to use
[ "Processes", "a", "user", "command", "using", "aliases" ]
train
https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/config.py#L276-L324
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.open
def open(self, filename): ''' Opens a database file ''' # Ensure old file is closed before opening a new one self.close() self._f = open(filename, 'rb') self._dbtype = struct.unpack('B', self._f.read(1))[0] self._dbcolumn = struct.unpack('B', self._f.read(1))[0] ...
python
def open(self, filename): ''' Opens a database file ''' # Ensure old file is closed before opening a new one self.close() self._f = open(filename, 'rb') self._dbtype = struct.unpack('B', self._f.read(1))[0] self._dbcolumn = struct.unpack('B', self._f.read(1))[0] ...
[ "def", "open", "(", "self", ",", "filename", ")", ":", "# Ensure old file is closed before opening a new one", "self", ".", "close", "(", ")", "self", ".", "_f", "=", "open", "(", "filename", ",", "'rb'", ")", "self", ".", "_dbtype", "=", "struct", ".", "u...
Opens a database file
[ "Opens", "a", "database", "file" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L105-L121
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_country_short
def get_country_short(self, ip): ''' Get country_short ''' rec = self.get_all(ip) return rec and rec.country_short
python
def get_country_short(self, ip): ''' Get country_short ''' rec = self.get_all(ip) return rec and rec.country_short
[ "def", "get_country_short", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "country_short" ]
Get country_short
[ "Get", "country_short" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L129-L132
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_country_long
def get_country_long(self, ip): ''' Get country_long ''' rec = self.get_all(ip) return rec and rec.country_long
python
def get_country_long(self, ip): ''' Get country_long ''' rec = self.get_all(ip) return rec and rec.country_long
[ "def", "get_country_long", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "country_long" ]
Get country_long
[ "Get", "country_long" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L133-L136
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_region
def get_region(self, ip): ''' Get region ''' rec = self.get_all(ip) return rec and rec.region
python
def get_region(self, ip): ''' Get region ''' rec = self.get_all(ip) return rec and rec.region
[ "def", "get_region", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "region" ]
Get region
[ "Get", "region" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L137-L140
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_city
def get_city(self, ip): ''' Get city ''' rec = self.get_all(ip) return rec and rec.city
python
def get_city(self, ip): ''' Get city ''' rec = self.get_all(ip) return rec and rec.city
[ "def", "get_city", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "city" ]
Get city
[ "Get", "city" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L141-L144
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_isp
def get_isp(self, ip): ''' Get isp ''' rec = self.get_all(ip) return rec and rec.isp
python
def get_isp(self, ip): ''' Get isp ''' rec = self.get_all(ip) return rec and rec.isp
[ "def", "get_isp", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "isp" ]
Get isp
[ "Get", "isp" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L145-L148
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_latitude
def get_latitude(self, ip): ''' Get latitude ''' rec = self.get_all(ip) return rec and rec.latitude
python
def get_latitude(self, ip): ''' Get latitude ''' rec = self.get_all(ip) return rec and rec.latitude
[ "def", "get_latitude", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "latitude" ]
Get latitude
[ "Get", "latitude" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L149-L152
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_longitude
def get_longitude(self, ip): ''' Get longitude ''' rec = self.get_all(ip) return rec and rec.longitude
python
def get_longitude(self, ip): ''' Get longitude ''' rec = self.get_all(ip) return rec and rec.longitude
[ "def", "get_longitude", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "longitude" ]
Get longitude
[ "Get", "longitude" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L153-L156
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_domain
def get_domain(self, ip): ''' Get domain ''' rec = self.get_all(ip) return rec and rec.domain
python
def get_domain(self, ip): ''' Get domain ''' rec = self.get_all(ip) return rec and rec.domain
[ "def", "get_domain", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "domain" ]
Get domain
[ "Get", "domain" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L157-L160
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_zipcode
def get_zipcode(self, ip): ''' Get zipcode ''' rec = self.get_all(ip) return rec and rec.zipcode
python
def get_zipcode(self, ip): ''' Get zipcode ''' rec = self.get_all(ip) return rec and rec.zipcode
[ "def", "get_zipcode", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "zipcode" ]
Get zipcode
[ "Get", "zipcode" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L161-L164
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_timezone
def get_timezone(self, ip): ''' Get timezone ''' rec = self.get_all(ip) return rec and rec.timezone
python
def get_timezone(self, ip): ''' Get timezone ''' rec = self.get_all(ip) return rec and rec.timezone
[ "def", "get_timezone", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "timezone" ]
Get timezone
[ "Get", "timezone" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L165-L168
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_netspeed
def get_netspeed(self, ip): ''' Get netspeed ''' rec = self.get_all(ip) return rec and rec.netspeed
python
def get_netspeed(self, ip): ''' Get netspeed ''' rec = self.get_all(ip) return rec and rec.netspeed
[ "def", "get_netspeed", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "netspeed" ]
Get netspeed
[ "Get", "netspeed" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L169-L172
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_idd_code
def get_idd_code(self, ip): ''' Get idd_code ''' rec = self.get_all(ip) return rec and rec.idd_code
python
def get_idd_code(self, ip): ''' Get idd_code ''' rec = self.get_all(ip) return rec and rec.idd_code
[ "def", "get_idd_code", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "idd_code" ]
Get idd_code
[ "Get", "idd_code" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L173-L176
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_area_code
def get_area_code(self, ip): ''' Get area_code ''' rec = self.get_all(ip) return rec and rec.area_code
python
def get_area_code(self, ip): ''' Get area_code ''' rec = self.get_all(ip) return rec and rec.area_code
[ "def", "get_area_code", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "area_code" ]
Get area_code
[ "Get", "area_code" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L177-L180
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_weather_code
def get_weather_code(self, ip): ''' Get weather_code ''' rec = self.get_all(ip) return rec and rec.weather_code
python
def get_weather_code(self, ip): ''' Get weather_code ''' rec = self.get_all(ip) return rec and rec.weather_code
[ "def", "get_weather_code", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "weather_code" ]
Get weather_code
[ "Get", "weather_code" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L181-L184
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_weather_name
def get_weather_name(self, ip): ''' Get weather_name ''' rec = self.get_all(ip) return rec and rec.weather_name
python
def get_weather_name(self, ip): ''' Get weather_name ''' rec = self.get_all(ip) return rec and rec.weather_name
[ "def", "get_weather_name", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "weather_name" ]
Get weather_name
[ "Get", "weather_name" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L185-L188
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_mcc
def get_mcc(self, ip): ''' Get mcc ''' rec = self.get_all(ip) return rec and rec.mcc
python
def get_mcc(self, ip): ''' Get mcc ''' rec = self.get_all(ip) return rec and rec.mcc
[ "def", "get_mcc", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "mcc" ]
Get mcc
[ "Get", "mcc" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L189-L192
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_mnc
def get_mnc(self, ip): ''' Get mnc ''' rec = self.get_all(ip) return rec and rec.mnc
python
def get_mnc(self, ip): ''' Get mnc ''' rec = self.get_all(ip) return rec and rec.mnc
[ "def", "get_mnc", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "mnc" ]
Get mnc
[ "Get", "mnc" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L193-L196
chrislim2888/IP2Location-Python
IP2Location.py
IP2Location.get_mobile_brand
def get_mobile_brand(self, ip): ''' Get mobile_brand ''' rec = self.get_all(ip) return rec and rec.mobile_brand
python
def get_mobile_brand(self, ip): ''' Get mobile_brand ''' rec = self.get_all(ip) return rec and rec.mobile_brand
[ "def", "get_mobile_brand", "(", "self", ",", "ip", ")", ":", "rec", "=", "self", ".", "get_all", "(", "ip", ")", "return", "rec", "and", "rec", ".", "mobile_brand" ]
Get mobile_brand
[ "Get", "mobile_brand" ]
train
https://github.com/chrislim2888/IP2Location-Python/blob/6b2a7d3a5e61c9f8efda5ae96c7064f9a7714621/IP2Location.py#L197-L200