index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
5,175
docutils.nodes
__add__
null
def __add__(self, other): return self.children + other
(self, other)
5,176
docutils.nodes
__bool__
Node instances are always true, even if they're empty. A node is more than a simple container. Its boolean "truth" does not depend on having one or more subnodes in the doctree. Use `len()` to check node length.
def __bool__(self): """ Node instances are always true, even if they're empty. A node is more than a simple container. Its boolean "truth" does not depend on having one or more subnodes in the doctree. Use `len()` to check node length. """ return True
(self)
5,177
docutils.nodes
__contains__
null
def __contains__(self, key): # Test for both, children and attributes with operator ``in``. if isinstance(key, str): return key in self.attributes return key in self.children
(self, key)
5,178
docutils.nodes
__delitem__
null
def __delitem__(self, key): if isinstance(key, str): del self.attributes[key] elif isinstance(key, int): del self.children[key] elif isinstance(key, slice): assert key.step in (None, 1), 'cannot handle slice with stride' del self.children[key.start:key.stop] else: ...
(self, key)
5,179
releases.models
__eq__
null
def __eq__(self, other): for attr in self._cmp_keys: if getattr(self, attr, None) != getattr(other, attr, None): return False return True
(self, other)
5,180
docutils.nodes
__getitem__
null
def __getitem__(self, key): if isinstance(key, str): return self.attributes[key] elif isinstance(key, int): return self.children[key] elif isinstance(key, slice): assert key.step in (None, 1), 'cannot handle slice with stride' return self.children[key.start:key.stop] else...
(self, key)
5,181
releases.models
__hash__
null
def __hash__(self): return reduce(xor, [hash(getattr(self, x)) for x in self._cmp_keys])
(self)
5,182
docutils.nodes
__iadd__
Append a node or a list of nodes to `self.children`.
def __iadd__(self, other): """Append a node or a list of nodes to `self.children`.""" if isinstance(other, Node): self.append(other) elif other is not None: self.extend(other) return self
(self, other)
5,183
docutils.nodes
__init__
null
def __init__(self, rawsource='', *children, **attributes): self.rawsource = rawsource """The raw text from which this element was constructed. NOTE: some elements do not set this value (default ''). """ self.children = [] """List of child nodes (elements and/or `Text`).""" self.extend(childr...
(self, rawsource='', *children, **attributes)
5,184
docutils.nodes
__len__
null
def __len__(self): return len(self.children)
(self)
5,185
docutils.nodes
__radd__
null
def __radd__(self, other): return other + self.children
(self, other)
5,186
releases.models
__repr__
null
def __repr__(self): flag = "" if self.backported: flag = "backported" elif self.major: flag = "major" elif self.spec: flag = self.spec if flag: flag = " ({})".format(flag) return "<{issue.type} #{issue.number}{flag}>".format( issue=self, flag=flag )
(self)
5,187
docutils.nodes
__setitem__
null
def __setitem__(self, key, item): if isinstance(key, str): self.attributes[str(key)] = item elif isinstance(key, int): self.setup_child(item) self.children[key] = item elif isinstance(key, slice): assert key.step in (None, 1), 'cannot handle slice with stride' for nod...
(self, key, item)
5,188
docutils.nodes
__str__
null
def __str__(self): if self.children: return '%s%s%s' % (self.starttag(), ''.join(str(c) for c in self.children), self.endtag()) else: return self.emptytag()
(self)
5,189
docutils.nodes
_dom_node
null
def _dom_node(self, domroot): element = domroot.createElement(self.tagname) for attribute, value in self.attlist(): if isinstance(value, list): value = ' '.join(serial_escape('%s' % (v,)) for v in value) element.setAttribute(attribute, '%s' % value) for child in self.children: ...
(self, domroot)
5,190
docutils.nodes
_fast_findall
Return iterator that only supports instance checks.
def _fast_findall(self, cls): """Return iterator that only supports instance checks.""" if isinstance(self, cls): yield self for child in self.children: yield from child._fast_findall(cls)
(self, cls)
5,191
docutils.nodes
_superfast_findall
Return iterator that doesn't check for a condition.
def _superfast_findall(self): """Return iterator that doesn't check for a condition.""" # This is different from ``iter(self)`` implemented via # __getitem__() and __len__() in the Element subclass, # which yields only the direct children. yield self for child in self.children: yield fro...
(self)
5,192
releases.models
add_to_manager
Given a 'manager' structure, add self to one or more of its 'buckets'.
def add_to_manager(self, manager): """ Given a 'manager' structure, add self to one or more of its 'buckets'. """ # Derive version spec allowing us to filter against major/minor buckets spec = self.spec or self.default_spec(manager) # Only look in appropriate major version/family; if self is an ...
(self, manager)
5,193
docutils.nodes
append
null
def append(self, item): self.setup_child(item) self.children.append(item)
(self, item)
5,194
docutils.nodes
append_attr_list
For each element in values, if it does not exist in self[attr], append it. NOTE: Requires self[attr] and values to be sequence type and the former should specifically be a list.
def append_attr_list(self, attr, values): """ For each element in values, if it does not exist in self[attr], append it. NOTE: Requires self[attr] and values to be sequence type and the former should specifically be a list. """ # List Concatenation for value in values: if value n...
(self, attr, values)
5,195
docutils.nodes
asdom
Return a DOM **fragment** representation of this Node.
def asdom(self, dom=None): """Return a DOM **fragment** representation of this Node.""" if dom is None: import xml.dom.minidom as dom domroot = dom.Document() return self._dom_node(domroot)
(self, dom=None)
5,196
docutils.nodes
astext
null
def astext(self): return self.child_text_separator.join( [child.astext() for child in self.children])
(self)
5,197
docutils.nodes
attlist
null
def attlist(self): return sorted(self.non_default_attributes().items())
(self)
5,198
docutils.nodes
clear
null
def clear(self): self.children = []
(self)
5,199
docutils.nodes
coerce_append_attr_list
First, convert both self[attr] and value to a non-string sequence type; if either is not already a sequence, convert it to a list of one element. Then call append_attr_list. NOTE: self[attr] and value both must not be None.
def coerce_append_attr_list(self, attr, value): """ First, convert both self[attr] and value to a non-string sequence type; if either is not already a sequence, convert it to a list of one element. Then call append_attr_list. NOTE: self[attr] and value both must not be None. """ # List Conc...
(self, attr, value)
5,200
docutils.nodes
copy
null
def copy(self): obj = self.__class__(rawsource=self.rawsource, **self.attributes) obj._document = self._document obj.source = self.source obj.line = self.line return obj
(self)
5,201
docutils.nodes
copy_attr_coerce
If attr is an attribute of self and either self[attr] or value is a list, convert all non-sequence values to a sequence of 1 element and then concatenate the two sequence, setting the result to self[attr]. If both self[attr] and value are non-sequences and replace is True or sel...
def copy_attr_coerce(self, attr, value, replace): """ If attr is an attribute of self and either self[attr] or value is a list, convert all non-sequence values to a sequence of 1 element and then concatenate the two sequence, setting the result to self[attr]. If both self[attr] and value are non-seq...
(self, attr, value, replace)
5,202
docutils.nodes
copy_attr_concatenate
If attr is an attribute of self and both self[attr] and value are lists, concatenate the two sequences, setting the result to self[attr]. If either self[attr] or value are non-sequences and replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do noth...
def copy_attr_concatenate(self, attr, value, replace): """ If attr is an attribute of self and both self[attr] and value are lists, concatenate the two sequences, setting the result to self[attr]. If either self[attr] or value are non-sequences and replace is True or self[attr] is None, replace sel...
(self, attr, value, replace)
5,203
docutils.nodes
copy_attr_consistent
If replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do nothing.
def copy_attr_consistent(self, attr, value, replace): """ If replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do nothing. """ if self.get(attr) is not value: self.replace_attr(attr, value, replace)
(self, attr, value, replace)
5,204
docutils.nodes
copy_attr_convert
If attr is an attribute of self, set self[attr] to [self[attr], value], otherwise set self[attr] to value. NOTE: replace is not used by this function and is kept only for compatibility with the other copy functions.
def copy_attr_convert(self, attr, value, replace=True): """ If attr is an attribute of self, set self[attr] to [self[attr], value], otherwise set self[attr] to value. NOTE: replace is not used by this function and is kept only for compatibility with the other copy functions. """ if sel...
(self, attr, value, replace=True)
5,205
docutils.nodes
deepcopy
null
def deepcopy(self): copy = self.copy() copy.extend([child.deepcopy() for child in self.children]) return copy
(self)
5,206
releases.models
default_spec
Given the current release-lines structure, return a default Spec. Specifics: * For feature-like issues, only the highest major release is used, so given a ``manager`` with top level keys of ``[1, 2]``, this would return ``Spec(">=2")``. * When ``releases_alway...
def default_spec(self, manager): """ Given the current release-lines structure, return a default Spec. Specifics: * For feature-like issues, only the highest major release is used, so given a ``manager`` with top level keys of ``[1, 2]``, this would return ``Spec(">=2")``. * When ``r...
(self, manager)
5,207
docutils.nodes
delattr
null
def delattr(self, attr): if attr in self.attributes: del self.attributes[attr]
(self, attr)
5,208
docutils.nodes
emptytag
null
def emptytag(self): attributes = ('%s="%s"' % (n, v) for n, v in self.attlist()) return '<%s/>' % ' '.join((self.tagname, *attributes))
(self)
5,209
docutils.nodes
endtag
null
def endtag(self): return '</%s>' % self.tagname
(self)
5,210
docutils.nodes
extend
null
def extend(self, item): for node in item: self.append(node)
(self, item)
5,211
docutils.nodes
findall
Return an iterator yielding nodes following `self`: * self (if `include_self` is true) * all descendants in tree traversal order (if `descend` is true) * the following siblings (if `siblings` is true) and their descendants (if also `descend` is true) * the following s...
def findall(self, condition=None, include_self=True, descend=True, siblings=False, ascend=False): """ Return an iterator yielding nodes following `self`: * self (if `include_self` is true) * all descendants in tree traversal order (if `descend` is true) * the following siblings (if `sibl...
(self, condition=None, include_self=True, descend=True, siblings=False, ascend=False)
5,212
docutils.nodes
first_child_matching_class
Return the index of the first child whose class exactly matches. Parameters: - `childclass`: A `Node` subclass to search for, or a tuple of `Node` classes. If a tuple, any of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* ch...
def first_child_matching_class(self, childclass, start=0, end=sys.maxsize): """ Return the index of the first child whose class exactly matches. Parameters: - `childclass`: A `Node` subclass to search for, or a tuple of `Node` classes. If a tuple, any of the classes may match. - `start`: Initi...
(self, childclass, start=0, end=9223372036854775807)
5,213
docutils.nodes
first_child_not_matching_class
Return the index of the first child whose class does *not* match. Parameters: - `childclass`: A `Node` subclass to skip, or a tuple of `Node` classes. If a tuple, none of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* check....
def first_child_not_matching_class(self, childclass, start=0, end=sys.maxsize): """ Return the index of the first child whose class does *not* match. Parameters: - `childclass`: A `Node` subclass to skip, or a tuple of `Node` classes. If a tuple, none of the clas...
(self, childclass, start=0, end=9223372036854775807)
5,214
docutils.nodes
get
null
def get(self, key, failobj=None): return self.attributes.get(key, failobj)
(self, key, failobj=None)
5,215
docutils.nodes
get_language_code
Return node's language tag. Look iteratively in self and parents for a class argument starting with ``language-`` and return the remainder of it (which should be a `BCP49` language tag) or the `fallback`.
def get_language_code(self, fallback=''): """Return node's language tag. Look iteratively in self and parents for a class argument starting with ``language-`` and return the remainder of it (which should be a `BCP49` language tag) or the `fallback`. """ for cls in self.get('classes', []): ...
(self, fallback='')
5,216
docutils.nodes
hasattr
null
def hasattr(self, attr): return attr in self.attributes
(self, attr)
5,218
docutils.nodes
index
null
def index(self, item, start=0, stop=sys.maxsize): return self.children.index(item, start, stop)
(self, item, start=0, stop=9223372036854775807)
5,219
docutils.nodes
insert
null
def insert(self, index, item): if isinstance(item, Node): self.setup_child(item) self.children.insert(index, item) elif item is not None: self[index:index] = item
(self, index, item)
5,220
docutils.nodes
is_not_default
null
def is_not_default(self, key): if self[key] == [] and key in self.list_attributes: return 0 else: return 1
(self, key)
5,221
releases.models
minor_releases
Return all minor release line labels found in ``manager``.
def minor_releases(self, manager): """ Return all minor release line labels found in ``manager``. """ # TODO: yea deffo need a real object for 'manager', heh. E.g. we do a # very similar test for "do you have any actual releases yet?" # elsewhere. (This may be fodder for changing how we roll up ...
(self, manager)
5,222
docutils.nodes
next_node
Return the first node in the iterator returned by findall(), or None if the iterable is empty. Parameter list is the same as of `findall()`. Note that `include_self` defaults to False, though.
def next_node(self, condition=None, include_self=False, descend=True, siblings=False, ascend=False): """ Return the first node in the iterator returned by findall(), or None if the iterable is empty. Parameter list is the same as of `findall()`. Note that `include_self` defaults to Fa...
(self, condition=None, include_self=False, descend=True, siblings=False, ascend=False)
5,223
docutils.nodes
non_default_attributes
null
def non_default_attributes(self): atts = {} for key, value in self.attributes.items(): if self.is_not_default(key): atts[key] = value return atts
(self)
5,224
docutils.nodes
note_referenced_by
Note that this Element has been referenced by its name `name` or id `id`.
def note_referenced_by(self, name=None, id=None): """Note that this Element has been referenced by its name `name` or id `id`.""" self.referenced = True # Element.expect_referenced_by_* dictionaries map names or ids # to nodes whose ``referenced`` attribute is set to true as # soon as this node ...
(self, name=None, id=None)
5,225
docutils.nodes
pformat
null
def pformat(self, indent=' ', level=0): tagline = '%s%s\n' % (indent*level, self.starttag()) childreps = (c.pformat(indent, level+1) for c in self.children) return ''.join((tagline, *childreps))
(self, indent=' ', level=0)
5,226
docutils.nodes
pop
null
def pop(self, i=-1): return self.children.pop(i)
(self, i=-1)
5,227
docutils.nodes
previous_sibling
Return preceding sibling node or ``None``.
def previous_sibling(self): """Return preceding sibling node or ``None``.""" try: i = self.parent.index(self) except (AttributeError): return None return self.parent[i-1] if i > 0 else None
(self)
5,228
docutils.nodes
remove
null
def remove(self, item): self.children.remove(item)
(self, item)
5,229
docutils.nodes
replace
Replace one child `Node` with another child or children.
def replace(self, old, new): """Replace one child `Node` with another child or children.""" index = self.index(old) if isinstance(new, Node): self.setup_child(new) self[index] = new elif new is not None: self[index:index+1] = new
(self, old, new)
5,230
docutils.nodes
replace_attr
If self[attr] does not exist or force is True or omitted, set self[attr] to value, otherwise do nothing.
def replace_attr(self, attr, value, force=True): """ If self[attr] does not exist or force is True or omitted, set self[attr] to value, otherwise do nothing. """ # One or the other if force or self.get(attr) is None: self[attr] = value
(self, attr, value, force=True)
5,231
docutils.nodes
replace_self
Replace `self` node with `new`, where `new` is a node or a list of nodes.
def replace_self(self, new): """ Replace `self` node with `new`, where `new` is a node or a list of nodes. """ update = new if not isinstance(new, Node): # `new` is a list; update first child. try: update = new[0] except IndexError: update = None ...
(self, new)
5,232
docutils.nodes
set_class
Add a new class to the "classes" attribute.
def set_class(self, name): """Add a new class to the "classes" attribute.""" warnings.warn('docutils.nodes.Element.set_class() is deprecated; ' ' and will be removed in Docutils 0.21 or later.' "Append to Element['classes'] list attribute directly", Deprecat...
(self, name)
5,233
docutils.nodes
setdefault
null
def setdefault(self, key, failobj=None): return self.attributes.setdefault(key, failobj)
(self, key, failobj=None)
5,234
docutils.nodes
setup_child
null
def setup_child(self, child): child.parent = self if self.document: child.document = self.document if child.source is None: child.source = self.document.current_source if child.line is None: child.line = self.document.current_line
(self, child)
5,235
docutils.nodes
shortrepr
null
def shortrepr(self): if self['names']: return '<%s "%s"...>' % (self.__class__.__name__, '; '.join(self['names'])) else: return '<%s...>' % self.tagname
(self)
5,236
docutils.nodes
starttag
null
def starttag(self, quoteattr=None): # the optional arg is used by the docutils_xml writer if quoteattr is None: quoteattr = pseudo_quoteattr parts = [self.tagname] for name, value in self.attlist(): if value is None: # boolean attribute parts.append('%s="True"' % na...
(self, quoteattr=None)
5,237
docutils.nodes
traverse
Return list of nodes following `self`. For looping, Node.findall() is faster and more memory efficient.
def traverse(self, condition=None, include_self=True, descend=True, siblings=False, ascend=False): """Return list of nodes following `self`. For looping, Node.findall() is faster and more memory efficient. """ # traverse() may be eventually removed: warnings.warn('nodes.Node.traverse() ...
(self, condition=None, include_self=True, descend=True, siblings=False, ascend=False)
5,238
docutils.nodes
update_all_atts
Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in bo...
def update_all_atts(self, dict_, update_fun=copy_attr_consistent, replace=True, and_source=False): """ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in ...
(self, dict_, update_fun=<function Element.copy_attr_consistent at 0x7fc41c59f760>, replace=True, and_source=False)
5,239
docutils.nodes
update_all_atts_coercion
Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in bo...
def update_all_atts_coercion(self, dict_, replace=True, and_source=False): """ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, upda...
(self, dict_, replace=True, and_source=False)
5,240
docutils.nodes
update_all_atts_concatenating
Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in bo...
def update_all_atts_concatenating(self, dict_, replace=True, and_source=False): """ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in d...
(self, dict_, replace=True, and_source=False)
5,241
docutils.nodes
update_all_atts_consistantly
Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in bo...
def update_all_atts_consistantly(self, dict_, replace=True, and_source=False): """ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dic...
(self, dict_, replace=True, and_source=False)
5,242
docutils.nodes
update_all_atts_convert
Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in bo...
def update_all_atts_convert(self, dict_, and_source=False): """ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attrib...
(self, dict_, and_source=False)
5,243
docutils.nodes
update_basic_atts
Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary `dict_`.
def update_basic_atts(self, dict_): """ Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary `dict_`. """ if isinstance(dict_, Node): dict_ = dict_.attributes for att in self.basic_attributes: self.append_attr_list(att, dict_.g...
(self, dict_)
5,244
docutils.nodes
walk
Traverse a tree of `Node` objects, calling the `dispatch_visit()` method of `visitor` when entering each node. (The `walkabout()` method is similar, except it also calls the `dispatch_departure()` method before exiting each node.) This tree traversal supports limited i...
def walk(self, visitor): """ Traverse a tree of `Node` objects, calling the `dispatch_visit()` method of `visitor` when entering each node. (The `walkabout()` method is similar, except it also calls the `dispatch_departure()` method before exiting each node.) This tree traversal supports li...
(self, visitor)
5,245
docutils.nodes
walkabout
Perform a tree traversal similarly to `Node.walk()` (which see), except also call the `dispatch_departure()` method before exiting each node. Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` and ``depart`` implementation for each `Node` subclass encou...
def walkabout(self, visitor): """ Perform a tree traversal similarly to `Node.walk()` (which see), except also call the `dispatch_departure()` method before exiting each node. Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` and ``depart`` implementation for each `Node` su...
(self, visitor)
5,246
releases.line_manager
LineManager
Manages multiple release lines/families as well as related config state.
class LineManager(dict): """ Manages multiple release lines/families as well as related config state. """ def __init__(self, app): """ Initialize new line manager dict. :param app: The core Sphinx app object. Mostly used for config. """ super().__init__() ...
(app)
5,247
releases.line_manager
__init__
Initialize new line manager dict. :param app: The core Sphinx app object. Mostly used for config.
def __init__(self, app): """ Initialize new line manager dict. :param app: The core Sphinx app object. Mostly used for config. """ super().__init__() self.app = app
(self, app)
5,248
releases.line_manager
add_family
Expand to a new release line with given ``major_number``. This will flesh out mandatory buckets like ``unreleased_bugfix`` and do other necessary bookkeeping.
def add_family(self, major_number): """ Expand to a new release line with given ``major_number``. This will flesh out mandatory buckets like ``unreleased_bugfix`` and do other necessary bookkeeping. """ # Normally, we have separate buckets for bugfixes vs features keys = ["unreleased_bugfix"...
(self, major_number)
5,249
releases.models
Release
null
class Release(nodes.Element): @property def number(self): return self["number"] @property def minor(self): # TODO: use Version return ".".join(self.number.split(".")[:-1]) @property def family(self): # TODO: use Version.major # TODO: and probs just renam...
(rawsource='', *children, **attributes)
5,259
releases.models
__repr__
null
def __repr__(self): return "<release {}>".format(self.number)
(self)
5,316
semantic_version.base
Spec
null
class Spec(object): def __init__(self, *specs_strings): subspecs = [self.parse(spec) for spec in specs_strings] self.specs = sum(subspecs, ()) @classmethod def parse(self, specs_string): spec_texts = specs_string.split(',') return tuple(SpecItem(spec_text) for spec_text in s...
(*specs_strings)
5,317
semantic_version.base
__contains__
null
def __contains__(self, version): if isinstance(version, Version): return self.match(version) return False
(self, version)
5,318
semantic_version.base
__eq__
null
def __eq__(self, other): if not isinstance(other, Spec): return NotImplemented return set(self.specs) == set(other.specs)
(self, other)
5,319
semantic_version.base
__hash__
null
def __hash__(self): return hash(self.specs)
(self)
5,320
semantic_version.base
__init__
null
def __init__(self, *specs_strings): subspecs = [self.parse(spec) for spec in specs_strings] self.specs = sum(subspecs, ())
(self, *specs_strings)
5,321
semantic_version.base
__iter__
null
def __iter__(self): return iter(self.specs)
(self)
5,322
semantic_version.base
__repr__
null
def __repr__(self): return '<Spec: %r>' % (self.specs,)
(self)
5,323
semantic_version.base
__str__
null
def __str__(self): return ','.join(str(spec) for spec in self.specs)
(self)
5,324
semantic_version.base
filter
Filter an iterable of versions satisfying the Spec.
def filter(self, versions): """Filter an iterable of versions satisfying the Spec.""" for version in versions: if self.match(version): yield version
(self, versions)
5,325
semantic_version.base
match
Check whether a Version satisfies the Spec.
def match(self, version): """Check whether a Version satisfies the Spec.""" return all(spec.match(version) for spec in self.specs)
(self, version)
5,326
semantic_version.base
select
Select the best compatible version among an iterable of options.
def select(self, versions): """Select the best compatible version among an iterable of options.""" options = list(self.filter(versions)) if options: return max(options) return None
(self, versions)
5,327
releases.models
Version
Version subclass toggling ``partial=True`` by default.
class Version(StrictVersion): """ Version subclass toggling ``partial=True`` by default. """ def __init__(self, version_string, partial=True): super().__init__(version_string, partial)
(version_string, partial=True)
5,328
semantic_version.base
__compare
null
def __compare(self, other): comparison_functions = self._comparison_functions(partial=self.partial or other.partial) comparisons = zip(comparison_functions, self, other) for cmp_fun, self_field, other_field in comparisons: cmp_res = cmp_fun(self_field, other_field) if cmp_res != 0: ...
(self, other)
5,329
semantic_version.base
__compare_helper
Helper for comparison. Allows the caller to provide: - The condition - The return value if the comparison is meaningless (ie versions with build metadata).
def __compare_helper(self, other, condition, notimpl_target): """Helper for comparison. Allows the caller to provide: - The condition - The return value if the comparison is meaningless (ie versions with build metadata). """ if not isinstance(other, self.__class__): return NotImp...
(self, other, condition, notimpl_target)
5,330
semantic_version.base
__cmp__
null
def __cmp__(self, other): if not isinstance(other, self.__class__): return NotImplemented return self.__compare(other)
(self, other)
5,331
semantic_version.base
__eq__
null
def __eq__(self, other): return self.__compare_helper(other, lambda x: x == 0, notimpl_target=False)
(self, other)
5,332
semantic_version.base
__ge__
null
def __ge__(self, other): return self.__compare_helper(other, lambda x: x >= 0, notimpl_target=False)
(self, other)
5,333
semantic_version.base
__gt__
null
def __gt__(self, other): return self.__compare_helper(other, lambda x: x > 0, notimpl_target=False)
(self, other)
5,334
semantic_version.base
__hash__
null
def __hash__(self): return hash((self.major, self.minor, self.patch, self.prerelease, self.build))
(self)
5,335
releases.models
__init__
null
def __init__(self, version_string, partial=True): super().__init__(version_string, partial)
(self, version_string, partial=True)
5,336
semantic_version.base
__iter__
null
def __iter__(self): return iter((self.major, self.minor, self.patch, self.prerelease, self.build))
(self)
5,337
semantic_version.base
__le__
null
def __le__(self, other): return self.__compare_helper(other, lambda x: x <= 0, notimpl_target=False)
(self, other)
5,338
semantic_version.base
__lt__
null
def __lt__(self, other): return self.__compare_helper(other, lambda x: x < 0, notimpl_target=False)
(self, other)
5,339
semantic_version.base
__ne__
null
def __ne__(self, other): return self.__compare_helper(other, lambda x: x != 0, notimpl_target=True)
(self, other)
5,340
semantic_version.base
__repr__
null
def __repr__(self): return 'Version(%r%s)' % ( str(self), ', partial=True' if self.partial else '', )
(self)