text stringlengths 81 112k |
|---|
Override.
Make sure that the kind returned is the root class of the
polymorphic hierarchy.
def _get_kind(cls):
"""Override.
Make sure that the kind returned is the root class of the
polymorphic hierarchy.
"""
bases = cls._get_hierarchy()
if not bases:
# We have to jump through s... |
Internal helper to return the list of polymorphic base classes.
This returns a list of class objects, e.g. [Animal, Feline, Cat].
def _get_hierarchy(cls):
"""Internal helper to return the list of polymorphic base classes.
This returns a list of class objects, e.g. [Animal, Feline, Cat].
"""
bases... |
Returns all potential envs in a basedir
def find_env_paths_in_basedirs(base_dirs):
"""Returns all potential envs in a basedir"""
# get potential env path in the base_dirs
env_path = []
for base_dir in base_dirs:
env_path.extend(glob.glob(os.path.join(
os.path.expanduser(base_dir), '... |
Converts a list of paths to environments to env_data.
env_data is a structure {name -> (ressourcedir, kernel spec)}
def convert_to_env_data(mgr, env_paths, validator_func, activate_func,
name_template, display_name_template, name_prefix):
"""Converts a list of paths to environments to ... |
Validates that this env contains an IPython kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_dir)
def validate_IPykernel(venv_dir):
"""Validates that this env contains an IPython kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_dir... |
Validates that this env contains an IRkernel kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_dir)
def validate_IRkernel(venv_dir):
"""Validates that this env contains an IRkernel kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_di... |
Finds a exe with that name in the environment path
def find_exe(env_dir, name):
"""Finds a exe with that name in the environment path"""
if platform.system() == "Windows":
name = name + ".exe"
# find the binary
exe_name = os.path.join(env_dir, name)
if not os.path.exists(exe_name):
... |
Finds kernel specs from virtualenv environments
env_data is a structure {name -> (resourcedir, kernel spec)}
def get_virtualenv_env_data(mgr):
"""Finds kernel specs from virtualenv environments
env_data is a structure {name -> (resourcedir, kernel spec)}
"""
if not mgr.find_virtualenv_envs:
... |
Simply bash-specific wrapper around source-foreign
Returns a dict to be used as a new environment
def source_bash(args, stdin=None):
"""Simply bash-specific wrapper around source-foreign
Returns a dict to be used as a new environment"""
args = list(args)
new_args = ['bash', '--sourcer=source']
... |
Simply zsh-specific wrapper around source-foreign
Returns a dict to be used as a new environment
def source_zsh(args, stdin=None):
"""Simply zsh-specific wrapper around source-foreign
Returns a dict to be used as a new environment"""
args = list(args)
new_args = ['zsh', '--sourcer=source']
ne... |
Simple cmd.exe-specific wrapper around source-foreign.
returns a dict to be used as a new environment
def source_cmd(args, stdin=None):
"""Simple cmd.exe-specific wrapper around source-foreign.
returns a dict to be used as a new environment
"""
args = list(args)
fpath = locate_binary(args[0])... |
Returns an argument quoted in such a way that that CommandLineToArgvW
on Windows will return the argument string unchanged.
This is the same thing Popen does when supplied with an list of arguments.
Arguments in a command line should be separated by spaces; this
function does not add these spaces. This ... |
Returns a string that is usable by the Windows cmd.exe.
The escaping is based on details here and emperical testing:
http://www.robvanderwoude.com/escapechars.php
def escape_windows_cmd_string(s):
"""Returns a string that is usable by the Windows cmd.exe.
The escaping is based on details here and emper... |
Sources a file written in a foreign shell language.
def source_foreign(args, stdin=None):
"""Sources a file written in a foreign shell language."""
parser = _ensure_source_foreign_parser()
ns = parser.parse_args(args)
if ns.prevcmd is not None:
pass # don't change prevcmd if given explicitly
... |
Checks that path is an executable regular file, or a symlink towards one.
This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``.
This function was forked from pexpect originally:
Copyright (c) 2013-2014, Pexpect development team
Copyright (c) 2012, Noah Spurrier <noah@noah.org>
PE... |
Extracts data from a foreign (non-xonsh) shells. Currently this gets
the environment, aliases, and functions but may be extended in the future.
Parameters
----------
shell : str
The name of the shell, such as 'bash' or '/bin/sh'.
interactive : bool, optional
Whether the shell should... |
Converts to a boolean in a semantically meaningful way.
def to_bool(x):
""""Converts to a boolean in a semantically meaningful way."""
if isinstance(x, bool):
return x
elif isinstance(x, str):
return False if x.lower() in _FALSES else True
else:
return bool(x) |
Parses the environment portion of string into a dict.
def parse_env(s):
"""Parses the environment portion of string into a dict."""
m = ENV_RE.search(s)
if m is None:
return {}
g1 = m.group(1)
env = dict(ENV_SPLIT_RE.findall(g1))
return env |
Finds kernel specs from conda environments
env_data is a structure {name -> (resourcedir, kernel spec)}
def get_conda_env_data(mgr):
"""Finds kernel specs from conda environments
env_data is a structure {name -> (resourcedir, kernel spec)}
"""
if not mgr.find_conda_envs:
return {}
mg... |
Returns a list of path as given by `conda env list --json`.
Returns empty list, if conda couldn't be called.
def _find_conda_env_paths_from_conda(mgr):
"""Returns a list of path as given by `conda env list --json`.
Returns empty list, if conda couldn't be called.
"""
# this is expensive, so make ... |
Check the name of the environment against the black list and the
whitelist. If a whitelist is specified only it is checked.
def validate_env(self, envname):
"""
Check the name of the environment against the black list and the
whitelist. If a whitelist is specified only it is checked.
... |
Get the data about the available environments.
env_data is a structure {name -> (resourcedir, kernel spec)}
def _get_env_data(self, reload=False):
"""Get the data about the available environments.
env_data is a structure {name -> (resourcedir, kernel spec)}
"""
# This is call... |
Returns a dict mapping kernel names to resource directories.
def find_kernel_specs_for_envs(self):
"""Returns a dict mapping kernel names to resource directories."""
data = self._get_env_data()
return {name: data[name][0] for name in data} |
Returns the dict of name -> kernel_spec for all environments
def get_all_kernel_specs_for_envs(self):
"""Returns the dict of name -> kernel_spec for all environments"""
data = self._get_env_data()
return {name: data[name][1] for name in data} |
Returns a dict mapping kernel names to resource directories.
def find_kernel_specs(self):
"""Returns a dict mapping kernel names to resource directories."""
# let real installed kernels overwrite envs with the same name:
# this is the same order as the get_kernel_spec way, which also prefers
... |
Returns a dict mapping kernel names and resource directories.
def get_all_specs(self):
"""Returns a dict mapping kernel names and resource directories.
"""
# This is new in 4.1 -> https://github.com/jupyter/jupyter_client/pull/93
specs = self.get_all_kernel_specs_for_envs()
spec... |
Returns a :class:`KernelSpec` instance for the given kernel_name.
Raises :exc:`NoSuchKernel` if the given kernel name is not found.
def get_kernel_spec(self, kernel_name):
"""Returns a :class:`KernelSpec` instance for the given kernel_name.
Raises :exc:`NoSuchKernel` if the given kernel name ... |
Transliterate serbian cyrillic string of characters to latin string of characters.
:param string_to_transliterate: The cyrillic string to transliterate into latin characters.
:param lang_code: Indicates the cyrillic language code we are translating from. Defaults to Serbian (sr).
:return: A string of latin ... |
Transliterate serbian latin string of characters to cyrillic string of characters.
:param string_to_transliterate: The latin string to transliterate into cyrillic characters.
:param lang_code: Indicates the cyrillic language code we are translating to. Defaults to Serbian (sr).
:return: A string of cyrillic... |
Parses the incoming bytestream as XML and returns the resulting data.
def parse(self, stream, media_type=None, parser_context=None):
"""
Parses the incoming bytestream as XML and returns the resulting data.
"""
assert etree, 'XMLParser requires defusedxml to be installed'
parse... |
convert the xml `element` into the corresponding python object
def _xml_convert(self, element):
"""
convert the xml `element` into the corresponding python object
"""
children = list(element)
if len(children) == 0:
return self._type_convert(element.text)
el... |
Converts the value returned by the XMl parse into the equivalent
Python type
def _type_convert(self, value):
"""
Converts the value returned by the XMl parse into the equivalent
Python type
"""
if value is None:
return value
try:
return d... |
Renders `data` into serialized XML.
def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Renders `data` into serialized XML.
"""
if data is None:
return ''
stream = StringIO()
xml = SimplerXMLGenerator(stream, self.charset)
x... |
Open a connection to the device.
def open(self):
"""Open a connection to the device."""
device_type = 'cisco_ios'
if self.transport == 'telnet':
device_type = 'cisco_ios_telnet'
self.device = ConnectHandler(device_type=device_type,
host=s... |
Write temp file and for use with inline config and SCP.
def _create_tmp_file(config):
"""Write temp file and for use with inline config and SCP."""
tmp_dir = tempfile.gettempdir()
rand_fname = py23_compat.text_type(uuid.uuid4())
filename = os.path.join(tmp_dir, rand_fname)
with ... |
Transfer file to remote device for either merge or replace operations
Returns (return_status, msg)
def _load_candidate_wrapper(self, source_file=None, source_config=None, dest_file=None,
file_system=None):
"""
Transfer file to remote device for either merge or r... |
SCP file to device filesystem, defaults to candidate_config.
Return None or raise exception
def load_replace_candidate(self, filename=None, config=None):
"""
SCP file to device filesystem, defaults to candidate_config.
Return None or raise exception
"""
self.config_rep... |
SCP file to remote device.
Merge configuration in: copy <file> running-config
def load_merge_candidate(self, filename=None, config=None):
"""
SCP file to remote device.
Merge configuration in: copy <file> running-config
"""
self.config_replace = False
return_st... |
Special handler for hostname change on commit operation.
def _commit_hostname_handler(self, cmd):
"""Special handler for hostname change on commit operation."""
current_prompt = self.device.find_prompt().strip()
terminating_char = current_prompt[-1]
pattern = r"[>#{}]\s*$".format(termin... |
If replacement operation, perform 'configure replace' for the entire config.
If merge operation, perform copy <file> running-config.
def commit_config(self):
"""
If replacement operation, perform 'configure replace' for the entire config.
If merge operation, perform copy <file> runnin... |
Set candidate_cfg to current running-config. Erase the merge_cfg file.
def discard_config(self):
"""Set candidate_cfg to current running-config. Erase the merge_cfg file."""
discard_candidate = 'copy running-config {}'.format(self._gen_full_path(self.candidate_cfg))
discard_merge = 'copy null: ... |
Transfer file to remote device.
By default, this will use Secure Copy if self.inline_transfer is set, then will use
Netmiko InlineTransfer method to transfer inline using either SSH or telnet (plus TCL
onbox).
Return (status, msg)
status = boolean
msg = details on what ... |
Generate full file path on remote device.
def _gen_full_path(self, filename, file_system=None):
"""Generate full file path on remote device."""
if file_system is None:
return '{}/{}'.format(self.dest_file_system, filename)
else:
if ":" not in file_system:
... |
Save a configuration that can be used for rollback.
def _gen_rollback_cfg(self):
"""Save a configuration that can be used for rollback."""
cfg_file = self._gen_full_path(self.rollback_cfg)
cmd = 'copy running-config {}'.format(cfg_file)
self._disable_confirm()
self.device.send_c... |
Check that the file exists on remote device using full path.
cfg_file is full path i.e. flash:/file_name
For example
# dir flash:/candidate_config.txt
Directory of flash:/candidate_config.txt
33 -rw- 5592 Dec 18 2015 10:50:22 -08:00 candidate_config.txt
retu... |
Obtain the full interface name from the abbreviated name.
Cache mappings in self.interface_map.
def _expand_interface_name(self, interface_brief):
"""
Obtain the full interface name from the abbreviated name.
Cache mappings in self.interface_map.
"""
if self.interface_... |
IOS implementation of get_lldp_neighbors.
def get_lldp_neighbors(self):
"""IOS implementation of get_lldp_neighbors."""
lldp = {}
command = 'show lldp neighbors'
output = self._send_command(command)
# Check if router supports the command
if '% Invalid input' in output:
... |
IOS implementation of get_lldp_neighbors_detail.
Calls get_lldp_neighbors.
def get_lldp_neighbors_detail(self, interface=''):
"""
IOS implementation of get_lldp_neighbors_detail.
Calls get_lldp_neighbors.
"""
lldp = {}
lldp_neighbors = self.get_lldp_neighbors()... |
Return a set of facts from the devices.
def get_facts(self):
"""Return a set of facts from the devices."""
# default values.
vendor = u'Cisco'
uptime = -1
serial_number, fqdn, os_version, hostname, domain_name = ('Unknown',) * 5
# obtain output from device
show_... |
Get interface details.
last_flapped is not implemented
Example Output:
{ u'Vlan1': { 'description': u'N/A',
'is_enabled': True,
'is_up': True,
'last_flapped': -1.0,
'mac_address': u'a493.4cc1.67a7',
... |
Get interface ip details.
Returns a dict of dicts
Example Output:
{ u'FastEthernet8': { 'ipv4': { u'10.66.43.169': { 'prefix_length': 22}}},
u'Loopback555': { 'ipv4': { u'192.168.1.1': { 'prefix_length': 24}},
'ipv6': { u'1::1': { ... |
Convert string time to seconds.
Examples
00:14:23
00:13:40
00:00:21
00:00:13
00:00:49
1d11h
1d17h
1w0d
8w5d
1y28w
never
def bgp_time_conversion(bgp_uptime):
"""
Convert string time to seconds.
Exam... |
BGP neighbor information.
Currently no VRF support. Supports both IPv4 and IPv6.
def get_bgp_neighbors(self):
"""BGP neighbor information.
Currently no VRF support. Supports both IPv4 and IPv6.
"""
supported_afi = ['ipv4', 'ipv6']
bgp_neighbor_data = dict()
bg... |
Get environment facts.
power and fan are currently not implemented
cpu is using 1-minute average
cpu hard-coded to cpu0 (i.e. only a single CPU)
def get_environment(self):
"""
Get environment facts.
power and fan are currently not implemented
cpu is using 1-min... |
Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
'interface' : 'MgmtEth0/RSP0/CPU0... |
Execute a list of commands and return the output in a dictionary format using the command
as the key.
Example input:
['show clock', 'show calendar']
Output example:
{ 'show calendar': u'22:02:01 UTC Thu Feb 18 2016',
'show clock': u'*22:01:51.165 UTC Thu Feb 18 20... |
Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address
Table, having the following keys
* mac (string)
* interface (string)
* vlan (int)
* active (boolean)
* static (boolean)
* moves (int)
* last... |
Executes traceroute on the device and returns a dictionary with the result.
:param destination: Host or IP Address of the destination
:param source (optional): Use a specific IP Address to execute the traceroute
:param ttl (optional): Maimum number of hops -> int (0-255)
:param timeout ... |
Implementation of get_config for IOS.
Returns the startup or/and running configuration as dictionary.
The keys of the dictionary represent the type of configuration
(startup or running). The candidate is always empty string,
since IOS does not support candidate configuration.
def get_c... |
Set the range of the accelerometer to the provided value. Range value
should be one of these constants:
- ADXL345_RANGE_2_G = +/-2G
- ADXL345_RANGE_4_G = +/-4G
- ADXL345_RANGE_8_G = +/-8G
- ADXL345_RANGE_16_G = +/-16G
def set_range(self, value):
"""Set th... |
Read the current value of the accelerometer and return it as a tuple
of signed 16-bit X, Y, Z axis values.
def read(self):
"""Read the current value of the accelerometer and return it as a tuple
of signed 16-bit X, Y, Z axis values.
"""
raw = self._device.readList(ADXL345_REG_DA... |
Stops interrupts on all boards. Only required when using
:func:`digital_read` and :func:`digital_write`.
:param bus: SPI bus /dev/spidev<bus>.<chipselect> (default: {bus})
:type bus: int
:param chip_select: SPI chip select /dev/spidev<bus>.<chipselect>
(default: {chip})
:type chip_select: i... |
Writes the value to the input pin specified.
.. note:: This function is for familiarality with users of other types of
IO board. Consider accessing the ``output_pins`` attribute of a
PiFaceDigital object:
>>> pfd = PiFaceDigital(hardware_addr)
>>> pfd.output_pins[pin_num].value = 1
... |
Writes the value to the input pullup specified.
.. note:: This function is for familiarality with users of other types of
IO board. Consider accessing the ``gppub`` attribute of a
PiFaceDigital object:
>>> pfd = PiFaceDigital(hardware_addr)
>>> hex(pfd.gppub.value)
0xff
>... |
Returns this computers IP address as a string.
def get_my_ip():
"""Returns this computers IP address as a string."""
ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1]
return ip.strip() |
Sets the output port value to new_value, defaults to old_value.
def set_output_port(self, new_value, old_value=0):
"""Sets the output port value to new_value, defaults to old_value."""
print("Setting output port to {}.".format(new_value))
port_value = old_value
try:
port_val... |
Wrap the calls the url, with the given arguments.
:param str url: Url to call with the given arguments
:param str method: [POST | GET] Method to use on the request
:param int status: Expected status code
def _request_api(self, **kwargs):
"""Wrap the calls the url, with the given argume... |
Get info about a user based on his id.
:return: JSON
def get_infos_with_id(self, uid):
"""Get info about a user based on his id.
:return: JSON
"""
_logid = uid
_user_info_url = USER_INFO_URL.format(logid=_logid)
return self._request_api(url=_user_info_url).jso... |
Get the current activities of user.
Either use the `login` param, or the client's login if unset.
:return: JSON
def get_current_activities(self, login=None, **kwargs):
"""Get the current activities of user.
Either use the `login` param, or the client's login if unset.
:return:... |
Get the current notifications of a user.
:return: JSON
def get_notifications(self, login=None, **kwargs):
"""Get the current notifications of a user.
:return: JSON
"""
_login = kwargs.get(
'login',
login or self._login
)
_notif_url = NO... |
Get a user's grades on a single promotion based on his login.
Either use the `login` param, or the client's login if unset.
:return: JSON
def get_grades(self, login=None, promotion=None, **kwargs):
"""Get a user's grades on a single promotion based on his login.
Either use the `login`... |
Get a user's picture.
:param str login: Login of the user to check
:return: JSON
def get_picture(self, login=None, **kwargs):
"""Get a user's picture.
:param str login: Login of the user to check
:return: JSON
"""
_login = kwargs.get(
'login',
... |
Get a user's project.
:param str login: User's login (Default: self._login)
:return: JSON
def get_projects(self, **kwargs):
"""Get a user's project.
:param str login: User's login (Default: self._login)
:return: JSON
"""
_login = kwargs.get('login', self._logi... |
Get the related activities of a project.
:param str module: Stages of a given module
:return: JSON
def get_activities_for_project(self, module=None, **kwargs):
"""Get the related activities of a project.
:param str module: Stages of a given module
:return: JSON
"""
... |
Get groups for activity.
:param str module: Base module
:param str module: Project which contains the group requested
:return: JSON
def get_group_for_activity(self, module=None, project=None, **kwargs):
"""Get groups for activity.
:param str module: Base module
:param ... |
Get users by promotion id.
:param int promotion: Promotion ID
:return: JSON
def get_students(self, **kwargs):
"""Get users by promotion id.
:param int promotion: Promotion ID
:return: JSON
"""
_promotion_id = kwargs.get('promotion')
_url = PROMOTION_UR... |
Get a user's log events.
:param str login: User's login (Default: self._login)
:return: JSON
def get_log_events(self, login=None, **kwargs):
"""Get a user's log events.
:param str login: User's login (Default: self._login)
:return: JSON
"""
_login = kwargs.get... |
Get a user's events.
:param str login: User's login (Default: self._login)
:param str start_date: Start date
:param str end_date: To date
:return: JSON
def get_events(self, login=None, start_date=None, end_date=None, **kwargs):
"""Get a user's events.
:param str login:... |
Get a user's logs.
:param str login: User's login (Default: self._login)
:return: JSON
def get_logs(self, login=None, **kwargs):
"""Get a user's logs.
:param str login: User's login (Default: self._login)
:return: JSON
"""
_login = kwargs.get(
'log... |
Process headers dict to return the format class
(not the instance)
def negotiate(cls, headers):
""" Process headers dict to return the format class
(not the instance)
"""
# set lower keys
headers = {k.lower(): v for k, v in headers.items()}
accept = head... |
Registers a collector
def register(self, collector):
""" Registers a collector"""
if not isinstance(collector, Collector):
raise TypeError(
"Can't register instance, not a valid type of collector")
if collector.name in self.collectors:
raise ValueError("... |
Add works like replace, but only previously pushed metrics with the
same name (and the same job and instance) will be replaced.
(It uses HTTP method 'POST' to push to the Pushgateway.)
def add(self, registry):
""" Add works like replace, but only previously pushed metrics with the
... |
Push triggers a metric collection and pushes all collected metrics
to the Pushgateway specified by addr
Note that all previously pushed metrics with the same job and
instance will be replaced with the metrics pushed by this call.
(It uses HTTP method 'PUT' to push to the ... |
Marshalls a collector and returns the storage/transfer format in
a tuple, this tuple has reprensentation format per element.
def marshall_lines(self, collector):
""" Marshalls a collector and returns the storage/transfer format in
a tuple, this tuple has reprensentation format per eleme... |
Marshalls a full registry (various collectors)
def marshall(self, registry):
"""Marshalls a full registry (various collectors)"""
blocks = []
for i in registry.get_all():
blocks.append(self.marshall_collector(i))
# Sort? used in tests
blocks = sorted(blocks)
... |
Returns bytes
def marshall(self, registry):
"""Returns bytes"""
result = b""
for i in registry.get_all():
# Each message needs to be prefixed with a varint with the size of
# the message (MetrycType)
# https://github.com/matttproud/golang_protobuf_extensions... |
Gathers the metrics
def gather_data(registry):
"""Gathers the metrics"""
# Get the host name of the machine
host = socket.gethostname()
# Create our collectors
trig_metric = Gauge("trigonometry_example",
"Various trigonometry examples.",
{'host': ho... |
Sets a value in the container
def set_value(self, labels, value):
""" Sets a value in the container"""
if labels:
self._label_names_correct(labels)
with mutex:
self.values[labels] = value |
Raise exception (ValueError) if labels not correct
def _label_names_correct(self, labels):
"""Raise exception (ValueError) if labels not correct"""
for k, v in labels.items():
# Check reserved labels
if k in RESTRICTED_LABELS_NAMES:
raise ValueError("Labels not ... |
Returns a list populated by tuples of 2 elements, first one is
a dict with all the labels and the second elemnt is the value
of the metric itself
def get_all(self):
""" Returns a list populated by tuples of 2 elements, first one is
a dict with all the labels and the second e... |
Add adds the given value to the Gauge. (The value can be
negative, resulting in a decrease of the Gauge.)
def add(self, labels, value):
""" Add adds the given value to the Gauge. (The value can be
negative, resulting in a decrease of the Gauge.)
"""
try:
cur... |
Add adds a single observation to the summary.
def add(self, labels, value):
"""Add adds a single observation to the summary."""
if type(value) not in (float, int):
raise TypeError("Summary only works with digits (int, float)")
# We have already a lock for data but not for the esti... |
Get gets the data in the form of 0.5, 0.9 and 0.99 percentiles. Also
you get sum and count, all in a dict
def get(self, labels):
""" Get gets the data in the form of 0.5, 0.9 and 0.99 percentiles. Also
you get sum and count, all in a dict
"""
return_data = {}
#... |
Gathers the metrics
def gather_data(registry):
"""Gathers the metrics"""
# Get the host name of the machine
host = socket.gethostname()
# Create our collectors
ram_metric = Gauge("memory_usage_bytes", "Memory usage in bytes.",
{'host': host})
cpu_metric = Gauge("cpu_usa... |
Gathers the metrics
def gather_data(registry):
"""Gathers the metrics"""
# Get the host name of the machine
host = socket.gethostname()
# Create our collectors
io_metric = Summary("write_file_io_example",
"Writing io file in disk example.",
{'host':... |
Returns the first child that matches the given name and
attributes.
def get_child(self, name, attribs=None):
"""
Returns the first child that matches the given name and
attributes.
"""
if name == '.':
if attribs is None or len(attribs) == 0:
r... |
Creates the given node, regardless of whether or not it already
exists.
Returns the new node.
def create(self, path, data=None):
"""
Creates the given node, regardless of whether or not it already
exists.
Returns the new node.
"""
node = self.current[-1]
... |
Creates the given node if it does not exist.
Returns the (new or existing) node.
def add(self, path, data=None, replace=False):
"""
Creates the given node if it does not exist.
Returns the (new or existing) node.
"""
node = self.current[-1]
for item in self._spli... |
Creates the given attribute and sets it to the given value.
Returns the (new or existing) node to which the attribute was added.
def add_attribute(self, path, name, value):
"""
Creates the given attribute and sets it to the given value.
Returns the (new or existing) node to which the at... |
Creates and enters the given node, regardless of whether it already
exists.
Returns the new node.
def open(self, path):
"""
Creates and enters the given node, regardless of whether it already
exists.
Returns the new node.
"""
self.current.append(self.crea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.