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_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
Hrabal/TemPy | tempy/t.py | TempyGod.from_string | def from_string(self, html_string):
"""Parses an html string and returns a list of Tempy trees."""
self._html_parser._reset().feed(html_string)
return self._html_parser.result | python | def from_string(self, html_string):
"""Parses an html string and returns a list of Tempy trees."""
self._html_parser._reset().feed(html_string)
return self._html_parser.result | Parses an html string and returns a list of Tempy trees. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/t.py#L104-L107 |
Hrabal/TemPy | tempy/t.py | TempyGod.dump | def dump(self, tempy_tree_list, filename, pretty=False):
"""Dumps a Tempy object to a python file"""
if not filename:
raise ValueError('"filename" argument should not be none.')
if len(filename.split(".")) > 1 and not filename.endswith(".py"):
raise ValueError(
... | python | def dump(self, tempy_tree_list, filename, pretty=False):
"""Dumps a Tempy object to a python file"""
if not filename:
raise ValueError('"filename" argument should not be none.')
if len(filename.split(".")) > 1 and not filename.endswith(".py"):
raise ValueError(
... | Dumps a Tempy object to a python file | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/t.py#L113-L129 |
Hrabal/TemPy | tempy/tempyrepr.py | _filter_classes | def _filter_classes(cls_list, cls_type):
"""Filters a list of classes and yields TempyREPR subclasses"""
for cls in cls_list:
if isinstance(cls, type) and issubclass(cls, cls_type):
if cls_type == TempyPlace and cls._base_place:
pass
else:
yield cl... | python | def _filter_classes(cls_list, cls_type):
"""Filters a list of classes and yields TempyREPR subclasses"""
for cls in cls_list:
if isinstance(cls, type) and issubclass(cls, cls_type):
if cls_type == TempyPlace and cls._base_place:
pass
else:
yield cl... | Filters a list of classes and yields TempyREPR subclasses | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempyrepr.py#L10-L17 |
Hrabal/TemPy | tempy/tempyrepr.py | REPRFinder._evaluate_tempyREPR | def _evaluate_tempyREPR(self, child, repr_cls):
"""Assign a score ito a TempyRepr class.
The scores depends on the current scope and position of the object in which the TempyREPR is found."""
score = 0
if repr_cls.__name__ == self.__class__.__name__:
# One point if the REPR h... | python | def _evaluate_tempyREPR(self, child, repr_cls):
"""Assign a score ito a TempyRepr class.
The scores depends on the current scope and position of the object in which the TempyREPR is found."""
score = 0
if repr_cls.__name__ == self.__class__.__name__:
# One point if the REPR h... | Assign a score ito a TempyRepr class.
The scores depends on the current scope and position of the object in which the TempyREPR is found. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempyrepr.py#L23-L42 |
Hrabal/TemPy | tempy/tempyrepr.py | REPRFinder._search_for_view | def _search_for_view(self, obj):
"""Searches for TempyREPR class declarations in the child's class.
If at least one TempyREPR is found, it uses the best one to make a Tempy object.
Otherwise the original object is returned.
"""
evaluator = partial(self._evaluate_tempyREPR, obj)
... | python | def _search_for_view(self, obj):
"""Searches for TempyREPR class declarations in the child's class.
If at least one TempyREPR is found, it uses the best one to make a Tempy object.
Otherwise the original object is returned.
"""
evaluator = partial(self._evaluate_tempyREPR, obj)
... | Searches for TempyREPR class declarations in the child's class.
If at least one TempyREPR is found, it uses the best one to make a Tempy object.
Otherwise the original object is returned. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempyrepr.py#L44-L58 |
Hrabal/TemPy | tempy/widgets.py | TempyPage.set_charset | def set_charset(self, charset):
"""Changes the <meta> charset tag (default charset in init is UTF-8)."""
self.head.charset.attr(charset=charset)
return self | python | def set_charset(self, charset):
"""Changes the <meta> charset tag (default charset in init is UTF-8)."""
self.head.charset.attr(charset=charset)
return self | Changes the <meta> charset tag (default charset in init is UTF-8). | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L65-L68 |
Hrabal/TemPy | tempy/widgets.py | TempyPage.set_description | def set_description(self, description):
"""Changes the <meta> description tag."""
self.head.description.attr(content=description)
return self | python | def set_description(self, description):
"""Changes the <meta> description tag."""
self.head.description.attr(content=description)
return self | Changes the <meta> description tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L70-L73 |
Hrabal/TemPy | tempy/widgets.py | TempyPage.set_keywords | def set_keywords(self, keywords):
"""Changes the <meta> keywords tag."""
self.head.keywords.attr(content=", ".join(keywords))
return self | python | def set_keywords(self, keywords):
"""Changes the <meta> keywords tag."""
self.head.keywords.attr(content=", ".join(keywords))
return self | Changes the <meta> keywords tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L75-L78 |
Hrabal/TemPy | tempy/widgets.py | TempyPage.set_title | def set_title(self, title):
"""Changes the <meta> title tag."""
self.head.title.attr(content=title)
return self | python | def set_title(self, title):
"""Changes the <meta> title tag."""
self.head.title.attr(content=title)
return self | Changes the <meta> title tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L80-L83 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.populate | def populate(self, data, resize_x=True, normalize=True):
"""Adds/Replace data in the table.
data: an iterable of iterables in the form [[col1, col2, col3], [col1, col2, col3]]
resize_x: if True, changes the x-size of the table according to the given data.
If False and data have dimen... | python | def populate(self, data, resize_x=True, normalize=True):
"""Adds/Replace data in the table.
data: an iterable of iterables in the form [[col1, col2, col3], [col1, col2, col3]]
resize_x: if True, changes the x-size of the table according to the given data.
If False and data have dimen... | Adds/Replace data in the table.
data: an iterable of iterables in the form [[col1, col2, col3], [col1, col2, col3]]
resize_x: if True, changes the x-size of the table according to the given data.
If False and data have dimensions different from the existing table structure a WidgetDataError ... | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L132-L169 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.add_row | def add_row(self, row_data, resize_x=True):
"""Adds a row at the end of the table"""
if not resize_x:
self._check_row_size(row_data)
self.body(Tr()(Td()(cell) for cell in row_data))
return self | python | def add_row(self, row_data, resize_x=True):
"""Adds a row at the end of the table"""
if not resize_x:
self._check_row_size(row_data)
self.body(Tr()(Td()(cell) for cell in row_data))
return self | Adds a row at the end of the table | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L174-L179 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.pop_row | def pop_row(self, idr=None, tags=False):
"""Pops a row, default the last"""
idr = idr if idr is not None else len(self.body) - 1
row = self.body.pop(idr)
return row if tags else [cell.childs[0] for cell in row] | python | def pop_row(self, idr=None, tags=False):
"""Pops a row, default the last"""
idr = idr if idr is not None else len(self.body) - 1
row = self.body.pop(idr)
return row if tags else [cell.childs[0] for cell in row] | Pops a row, default the last | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L181-L185 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.pop_cell | def pop_cell(self, idy=None, idx=None, tags=False):
"""Pops a cell, default the last of the last row"""
idy = idy if idy is not None else len(self.body) - 1
idx = idx if idx is not None else len(self.body[idy]) - 1
cell = self.body[idy].pop(idx)
return cell if tags else cell.chil... | python | def pop_cell(self, idy=None, idx=None, tags=False):
"""Pops a cell, default the last of the last row"""
idy = idy if idy is not None else len(self.body) - 1
idx = idx if idx is not None else len(self.body[idy]) - 1
cell = self.body[idy].pop(idx)
return cell if tags else cell.chil... | Pops a cell, default the last of the last row | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L187-L192 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.make_caption | def make_caption(self, caption):
"""Adds/Substitutes the table's caption."""
if not hasattr(self, "caption"):
self(caption=Caption())
return self.caption.empty()(caption) | python | def make_caption(self, caption):
"""Adds/Substitutes the table's caption."""
if not hasattr(self, "caption"):
self(caption=Caption())
return self.caption.empty()(caption) | Adds/Substitutes the table's caption. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L209-L213 |
Hrabal/TemPy | tempy/widgets.py | TempyTable.make_scope | def make_scope(self, col_scope_list=None, row_scope_list=None):
"""Makes scopes and converts Td to Th for given arguments
which represent lists of tuples (row_index, col_index)"""
if col_scope_list is not None and len(col_scope_list) > 0:
self.apply_scope(col_scope_list, "col")
... | python | def make_scope(self, col_scope_list=None, row_scope_list=None):
"""Makes scopes and converts Td to Th for given arguments
which represent lists of tuples (row_index, col_index)"""
if col_scope_list is not None and len(col_scope_list) > 0:
self.apply_scope(col_scope_list, "col")
... | Makes scopes and converts Td to Th for given arguments
which represent lists of tuples (row_index, col_index) | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L289-L296 |
Hrabal/TemPy | tempy/widgets.py | TempyListMeta.populate | def populate(self, struct):
"""Generates the list tree.
struct: if a list/set/tuple is given, a flat list is generated
<*l><li>v1</li><li>v2</li>...</*l>
If the list type is 'Dl' a flat list without definitions is generated
<*l><dt>v1</dt><dt>v2</dt>...</*l>
If the given... | python | def populate(self, struct):
"""Generates the list tree.
struct: if a list/set/tuple is given, a flat list is generated
<*l><li>v1</li><li>v2</li>...</*l>
If the list type is 'Dl' a flat list without definitions is generated
<*l><dt>v1</dt><dt>v2</dt>...</*l>
If the given... | Generates the list tree.
struct: if a list/set/tuple is given, a flat list is generated
<*l><li>v1</li><li>v2</li>...</*l>
If the list type is 'Dl' a flat list without definitions is generated
<*l><dt>v1</dt><dt>v2</dt>...</*l>
If the given struct is a dict, key contaninct lists... | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/widgets.py#L346-L395 |
Hrabal/TemPy | tempy/tags.py | Html.render | def render(self, *args, **kwargs):
"""Override so each html page served have a doctype"""
return self.doctype.render() + super().render(*args, **kwargs) | python | def render(self, *args, **kwargs):
"""Override so each html page served have a doctype"""
return self.doctype.render() + super().render(*args, **kwargs) | Override so each html page served have a doctype | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tags.py#L71-L73 |
Hrabal/TemPy | tempy/tags.py | A.render | def render(self, *args, **kwargs):
"""Override of the rendering so that if the link have no text in it, the href is used inside the <a> tag"""
if not self.childs and "href" in self.attrs:
return self.clone()(self.attrs["href"]).render(*args, **kwargs)
return super().render(*args, **k... | python | def render(self, *args, **kwargs):
"""Override of the rendering so that if the link have no text in it, the href is used inside the <a> tag"""
if not self.childs and "href" in self.attrs:
return self.clone()(self.attrs["href"]).render(*args, **kwargs)
return super().render(*args, **k... | Override of the rendering so that if the link have no text in it, the href is used inside the <a> tag | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tags.py#L79-L83 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator._find_content | def _find_content(self, cont_name):
"""Search for a content_name in the content data, if not found the parent is searched."""
try:
a = self.content_data[cont_name]
return a
except KeyError:
if self.parent:
return self.parent._find_content(cont_... | python | def _find_content(self, cont_name):
"""Search for a content_name in the content data, if not found the parent is searched."""
try:
a = self.content_data[cont_name]
return a
except KeyError:
if self.parent:
return self.parent._find_content(cont_... | Search for a content_name in the content data, if not found the parent is searched. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L26-L36 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator._get_non_tempy_contents | def _get_non_tempy_contents(self):
"""Returns rendered Contents and non-DOMElement stuff inside this Tag."""
for thing in filter(
lambda x: not issubclass(x.__class__, DOMElement), self.childs
):
yield thing | python | def _get_non_tempy_contents(self):
"""Returns rendered Contents and non-DOMElement stuff inside this Tag."""
for thing in filter(
lambda x: not issubclass(x.__class__, DOMElement), self.childs
):
yield thing | Returns rendered Contents and non-DOMElement stuff inside this Tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L38-L43 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.siblings | def siblings(self):
"""Returns all the siblings of this element as a list."""
return list(filter(lambda x: id(x) != id(self), self.parent.childs)) | python | def siblings(self):
"""Returns all the siblings of this element as a list."""
return list(filter(lambda x: id(x) != id(self), self.parent.childs)) | Returns all the siblings of this element as a list. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L129-L131 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.slice | def slice(self, start=None, end=None, step=None):
"""Slice of this element's childs as childs[start:end:step]"""
return self.childs[start:end:step] | python | def slice(self, start=None, end=None, step=None):
"""Slice of this element's childs as childs[start:end:step]"""
return self.childs[start:end:step] | Slice of this element's childs as childs[start:end:step] | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L137-L139 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.bft | def bft(self):
""" Generator that returns each element of the tree in Breadth-first order"""
queue = deque([self])
while queue:
node = queue.pop()
yield node
if hasattr(node, "childs"):
queue.extendleft(node.childs) | python | def bft(self):
""" Generator that returns each element of the tree in Breadth-first order"""
queue = deque([self])
while queue:
node = queue.pop()
yield node
if hasattr(node, "childs"):
queue.extendleft(node.childs) | Generator that returns each element of the tree in Breadth-first order | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L141-L148 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.dfs_preorder | def dfs_preorder(self, reverse=False):
"""Generator that returns each element of the tree in Preorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
stack.append(self)
while stack:
node = stack.pop()
... | python | def dfs_preorder(self, reverse=False):
"""Generator that returns each element of the tree in Preorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
stack.append(self)
while stack:
node = stack.pop()
... | Generator that returns each element of the tree in Preorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L150-L163 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.dfs_inorder | def dfs_inorder(self, reverse=False):
"""Generator that returns each element of the tree in Inorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
visited = set()
visited.add(self)
if reverse:
st... | python | def dfs_inorder(self, reverse=False):
"""Generator that returns each element of the tree in Inorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
visited = set()
visited.add(self)
if reverse:
st... | Generator that returns each element of the tree in Inorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L165-L191 |
Hrabal/TemPy | tempy/tempy.py | DOMNavigator.dfs_postorder | def dfs_postorder(self, reverse=False):
"""Generator that returns each element of the tree in Postorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
stack.append(self)
visited = set()
while stack:
... | python | def dfs_postorder(self, reverse=False):
"""Generator that returns each element of the tree in Postorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left."""
stack = deque()
stack.append(self)
visited = set()
while stack:
... | Generator that returns each element of the tree in Postorder order.
Keyword arguments:
reverse -- if true, the search is done from right to left. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L193-L211 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.content_receiver | def content_receiver(reverse=False):
"""Decorator for content adding methods.
Takes args and kwargs and calls the decorated method one time for each argument provided.
The reverse parameter should be used for prepending (relative to self) methods.
"""
def _receiver(func):
... | python | def content_receiver(reverse=False):
"""Decorator for content adding methods.
Takes args and kwargs and calls the decorated method one time for each argument provided.
The reverse parameter should be used for prepending (relative to self) methods.
"""
def _receiver(func):
... | Decorator for content adding methods.
Takes args and kwargs and calls the decorated method one time for each argument provided.
The reverse parameter should be used for prepending (relative to self) methods. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L215-L243 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier._insert | def _insert(self, dom_group, idx=None, prepend=False, name=None):
"""Inserts a DOMGroup inside this element.
If provided at the given index, if prepend at the start of the childs list, by default at the end.
If the child is a DOMElement, correctly links the child.
If the DOMGroup have a ... | python | def _insert(self, dom_group, idx=None, prepend=False, name=None):
"""Inserts a DOMGroup inside this element.
If provided at the given index, if prepend at the start of the childs list, by default at the end.
If the child is a DOMElement, correctly links the child.
If the DOMGroup have a ... | Inserts a DOMGroup inside this element.
If provided at the given index, if prepend at the start of the childs list, by default at the end.
If the child is a DOMElement, correctly links the child.
If the DOMGroup have a name, an attribute containing the child is created in this instance. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L245-L270 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.after | def after(self, i, sibling, name=None):
"""Adds siblings after the current tag."""
self.parent._insert(sibling, idx=self._own_index + 1 + i, name=name)
return self | python | def after(self, i, sibling, name=None):
"""Adds siblings after the current tag."""
self.parent._insert(sibling, idx=self._own_index + 1 + i, name=name)
return self | Adds siblings after the current tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L317-L320 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.prepend | def prepend(self, _, child, name=None):
"""Adds childs to this tag, starting from the first position."""
self._insert(child, prepend=True, name=name)
return self | python | def prepend(self, _, child, name=None):
"""Adds childs to this tag, starting from the first position."""
self._insert(child, prepend=True, name=name)
return self | Adds childs to this tag, starting from the first position. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L329-L332 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.append | def append(self, _, child, name=None):
"""Adds childs to this tag, after the current existing childs."""
self._insert(child, name=name)
return self | python | def append(self, _, child, name=None):
"""Adds childs to this tag, after the current existing childs."""
self._insert(child, name=name)
return self | Adds childs to this tag, after the current existing childs. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L340-L343 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.wrap | def wrap(self, other):
"""Wraps this element inside another empty tag."""
if other.childs:
raise TagError(self, "Wrapping in a non empty Tag is forbidden.")
if self.parent:
self.before(other)
self.parent.pop(self._own_index)
other.append(self)
... | python | def wrap(self, other):
"""Wraps this element inside another empty tag."""
if other.childs:
raise TagError(self, "Wrapping in a non empty Tag is forbidden.")
if self.parent:
self.before(other)
self.parent.pop(self._own_index)
other.append(self)
... | Wraps this element inside another empty tag. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L350-L358 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.wrap_many | def wrap_many(self, *args, strict=False):
"""Wraps different copies of this element inside all empty tags
listed in params or param's (non-empty) iterators.
Returns list of copies of this element wrapped inside args
or None if not succeeded, in the same order and same structure,
... | python | def wrap_many(self, *args, strict=False):
"""Wraps different copies of this element inside all empty tags
listed in params or param's (non-empty) iterators.
Returns list of copies of this element wrapped inside args
or None if not succeeded, in the same order and same structure,
... | Wraps different copies of this element inside all empty tags
listed in params or param's (non-empty) iterators.
Returns list of copies of this element wrapped inside args
or None if not succeeded, in the same order and same structure,
i.e. args = (Div(), (Div())) -> value = (A(...), (A(... | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L360-L420 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.replace_with | def replace_with(self, other):
"""Replace this element with the given DOMElement."""
self.after(other)
self.parent.pop(self._own_index)
return other | python | def replace_with(self, other):
"""Replace this element with the given DOMElement."""
self.after(other)
self.parent.pop(self._own_index)
return other | Replace this element with the given DOMElement. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L427-L431 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.remove | def remove(self):
"""Detach this element from his father."""
if self._own_index is not None and self.parent:
self.parent.pop(self._own_index)
return self | python | def remove(self):
"""Detach this element from his father."""
if self._own_index is not None and self.parent:
self.parent.pop(self._own_index)
return self | Detach this element from his father. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L433-L437 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier._detach_childs | def _detach_childs(self, idx_from=None, idx_to=None):
"""Moves all the childs to a new father"""
idx_from = idx_from or 0
idx_to = idx_to or len(self.childs)
removed = self.childs[idx_from:idx_to]
for child in removed:
if issubclass(child.__class__, DOMElement):
... | python | def _detach_childs(self, idx_from=None, idx_to=None):
"""Moves all the childs to a new father"""
idx_from = idx_from or 0
idx_to = idx_to or len(self.childs)
removed = self.childs[idx_from:idx_to]
for child in removed:
if issubclass(child.__class__, DOMElement):
... | Moves all the childs to a new father | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L439-L448 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.move | def move(self, new_father, idx=None, prepend=None, name=None):
"""Moves this element from his father to the given one."""
self.parent.pop(self._own_index)
new_father._insert(self, idx=idx, prepend=prepend, name=name)
new_father._stable = False
return self | python | def move(self, new_father, idx=None, prepend=None, name=None):
"""Moves this element from his father to the given one."""
self.parent.pop(self._own_index)
new_father._insert(self, idx=idx, prepend=prepend, name=name)
new_father._stable = False
return self | Moves this element from his father to the given one. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L455-L460 |
Hrabal/TemPy | tempy/tempy.py | DOMModifier.pop | def pop(self, arg=None):
"""Removes the child at given position or by name (or name iterator).
if no argument is given removes the last."""
self._stable = False
if arg is None:
arg = len(self.childs) - 1
if isinstance(arg, int):
try:
re... | python | def pop(self, arg=None):
"""Removes the child at given position or by name (or name iterator).
if no argument is given removes the last."""
self._stable = False
if arg is None:
arg = len(self.childs) - 1
if isinstance(arg, int):
try:
re... | Removes the child at given position or by name (or name iterator).
if no argument is given removes the last. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L462-L491 |
Hrabal/TemPy | tempy/tempy.py | DOMElement.data | def data(self, key=None, **kwargs):
"""Adds or retrieve extra data to this element, this data will not be rendered.
Every tag have a _data attribute (dict), if key is given _data[key] is returned.
Kwargs are used to udpate this Tag's _data."""
self.content_data.update(kwargs)
if ... | python | def data(self, key=None, **kwargs):
"""Adds or retrieve extra data to this element, this data will not be rendered.
Every tag have a _data attribute (dict), if key is given _data[key] is returned.
Kwargs are used to udpate this Tag's _data."""
self.content_data.update(kwargs)
if ... | Adds or retrieve extra data to this element, this data will not be rendered.
Every tag have a _data attribute (dict), if key is given _data[key] is returned.
Kwargs are used to udpate this Tag's _data. | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L675-L684 |
Hrabal/TemPy | tempy/tempy.py | DOMElement.inject | def inject(self, contents=None, **kwargs):
"""
Adds content data in this element. This will be used in the rendering of this element's childs.
Multiple injections on the same key will override the content (dict.update behavior).
"""
if contents and not isinstance(contents, dict):... | python | def inject(self, contents=None, **kwargs):
"""
Adds content data in this element. This will be used in the rendering of this element's childs.
Multiple injections on the same key will override the content (dict.update behavior).
"""
if contents and not isinstance(contents, dict):... | Adds content data in this element. This will be used in the rendering of this element's childs.
Multiple injections on the same key will override the content (dict.update behavior). | https://github.com/Hrabal/TemPy/blob/7d229b73e2ce3ccbb8254deae05c1f758f626ed6/tempy/tempy.py#L686-L699 |
bluedazzle/wechat_sender | wechat_sender/sender.py | Sender.send | def send(self, message):
"""
发送基本文字消息
:param message: (必填|str) - 需要发送的文本消息
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情
"""
url = '{0}message'.format(self.remote)
data = self._wrap_post_data(content=message)
res = requests.... | python | def send(self, message):
"""
发送基本文字消息
:param message: (必填|str) - 需要发送的文本消息
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情
"""
url = '{0}message'.format(self.remote)
data = self._wrap_post_data(content=message)
res = requests.... | 发送基本文字消息
:param message: (必填|str) - 需要发送的文本消息
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/sender.py#L60-L77 |
bluedazzle/wechat_sender | wechat_sender/sender.py | Sender.delay_send | def delay_send(self, content, time, title='', remind=DEFAULT_REMIND_TIME):
"""
发送延时消息
:param content: (必填|str) - 需要发送的消息内容
:param time: (必填|str|datetime) - 发送消息的开始时间,支持 datetime.date、datetime.datetime 格式或者如 '2017-05-21 10:00:00' 的字符串
:param title: (选填|str) - 需要发送的消息标题
:p... | python | def delay_send(self, content, time, title='', remind=DEFAULT_REMIND_TIME):
"""
发送延时消息
:param content: (必填|str) - 需要发送的消息内容
:param time: (必填|str|datetime) - 发送消息的开始时间,支持 datetime.date、datetime.datetime 格式或者如 '2017-05-21 10:00:00' 的字符串
:param title: (选填|str) - 需要发送的消息标题
:p... | 发送延时消息
:param content: (必填|str) - 需要发送的消息内容
:param time: (必填|str|datetime) - 发送消息的开始时间,支持 datetime.date、datetime.datetime 格式或者如 '2017-05-21 10:00:00' 的字符串
:param title: (选填|str) - 需要发送的消息标题
:param remind: (选填|int|datetime.timedelta) - 消息提醒时移,默认 1 小时,即早于 time 值 1 小时发送消息提醒, 支持 integer(毫秒)... | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/sender.py#L79-L105 |
bluedazzle/wechat_sender | wechat_sender/sender.py | Sender.periodic_send | def periodic_send(self, content, interval, title=''):
"""
发送周期消息
:param content: (必填|str) - 需要发送的消息内容
:param interval: (必填|int|datetime.timedelta) - 发送消息间隔时间,支持 datetime.timedelta 或 integer 表示的秒数
:param title: (选填|str) - 需要发送的消息标题
:return: * status:发送状态,True 发送成,False 发... | python | def periodic_send(self, content, interval, title=''):
"""
发送周期消息
:param content: (必填|str) - 需要发送的消息内容
:param interval: (必填|int|datetime.timedelta) - 发送消息间隔时间,支持 datetime.timedelta 或 integer 表示的秒数
:param title: (选填|str) - 需要发送的消息标题
:return: * status:发送状态,True 发送成,False 发... | 发送周期消息
:param content: (必填|str) - 需要发送的消息内容
:param interval: (必填|int|datetime.timedelta) - 发送消息间隔时间,支持 datetime.timedelta 或 integer 表示的秒数
:param title: (选填|str) - 需要发送的消息标题
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/sender.py#L107-L130 |
bluedazzle/wechat_sender | wechat_sender/sender.py | Sender.send_to | def send_to(self, content, search):
"""
向指定好友发送消息
:param content: (必填|str) - 需要发送的消息内容
:param search: (必填|str|dict|list)-搜索对象,同 wxpy.chats.search 使用方法一样。例如,可以使用字符串进行搜索好友或群,或指定具体属性搜索,如 puid=xxx 的字典
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情
... | python | def send_to(self, content, search):
"""
向指定好友发送消息
:param content: (必填|str) - 需要发送的消息内容
:param search: (必填|str|dict|list)-搜索对象,同 wxpy.chats.search 使用方法一样。例如,可以使用字符串进行搜索好友或群,或指定具体属性搜索,如 puid=xxx 的字典
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情
... | 向指定好友发送消息
:param content: (必填|str) - 需要发送的消息内容
:param search: (必填|str|dict|list)-搜索对象,同 wxpy.chats.search 使用方法一样。例如,可以使用字符串进行搜索好友或群,或指定具体属性搜索,如 puid=xxx 的字典
:return: * status:发送状态,True 发送成,False 发送失败
* message:发送失败详情 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/sender.py#L132-L154 |
bluedazzle/wechat_sender | wechat_sender/utils.py | _read_config_list | def _read_config_list():
"""
配置列表读取
"""
with codecs.open('conf.ini', 'w+', encoding='utf-8') as f1:
conf_list = [conf for conf in f1.read().split('\n') if conf != '']
return conf_list | python | def _read_config_list():
"""
配置列表读取
"""
with codecs.open('conf.ini', 'w+', encoding='utf-8') as f1:
conf_list = [conf for conf in f1.read().split('\n') if conf != '']
return conf_list | 配置列表读取 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/utils.py#L22-L28 |
bluedazzle/wechat_sender | wechat_sender/utils.py | write_config | def write_config(name, value):
"""
配置写入
"""
name = name.lower()
new = True
conf_list = _read_config_list()
for i, conf in enumerate(conf_list):
if conf.startswith(name):
conf_list[i] = '{0}={1}'.format(name, value)
new = False
break
if new:
... | python | def write_config(name, value):
"""
配置写入
"""
name = name.lower()
new = True
conf_list = _read_config_list()
for i, conf in enumerate(conf_list):
if conf.startswith(name):
conf_list[i] = '{0}={1}'.format(name, value)
new = False
break
if new:
... | 配置写入 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/utils.py#L31-L49 |
bluedazzle/wechat_sender | wechat_sender/utils.py | read_config | def read_config(name):
"""
配置读取
"""
name = name.lower()
conf_list = _read_config_list()
for conf in conf_list:
if conf.startswith(name):
return conf.split('=')[1].split('#')[0].strip()
return None | python | def read_config(name):
"""
配置读取
"""
name = name.lower()
conf_list = _read_config_list()
for conf in conf_list:
if conf.startswith(name):
return conf.split('=')[1].split('#')[0].strip()
return None | 配置读取 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/utils.py#L52-L61 |
bluedazzle/wechat_sender | wechat_sender/objects.py | WxBot.init_receivers | def init_receivers(self, receivers):
"""
初始化 receivers
"""
if not receivers:
self.default_receiver = self.bot.file_helper
return True
if isinstance(receivers, list):
self.default_receiver = receivers[0]
for receiver in receivers:
... | python | def init_receivers(self, receivers):
"""
初始化 receivers
"""
if not receivers:
self.default_receiver = self.bot.file_helper
return True
if isinstance(receivers, list):
self.default_receiver = receivers[0]
for receiver in receivers:
... | 初始化 receivers | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/objects.py#L32-L49 |
bluedazzle/wechat_sender | wechat_sender/objects.py | WxBot.send_msg | def send_msg(self, msg):
"""
wxpy 发送文本消息的基本封装,这里会进行消息 receiver 识别分发
"""
for receiver in msg.receivers:
current_receiver = self.receivers.get(receiver, self.default_receiver)
current_receiver.send_msg(msg) | python | def send_msg(self, msg):
"""
wxpy 发送文本消息的基本封装,这里会进行消息 receiver 识别分发
"""
for receiver in msg.receivers:
current_receiver = self.receivers.get(receiver, self.default_receiver)
current_receiver.send_msg(msg) | wxpy 发送文本消息的基本封装,这里会进行消息 receiver 识别分发 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/objects.py#L51-L57 |
bluedazzle/wechat_sender | wechat_sender/objects.py | Message.render_message | def render_message(self):
"""
渲染消息
:return: 渲染后的消息
"""
message = None
if self.title:
message = '标题:{0}'.format(self.title)
if self.message_time:
message = '{0}\n时间:{1}'.format(message, self.time)
if message:
message = '... | python | def render_message(self):
"""
渲染消息
:return: 渲染后的消息
"""
message = None
if self.title:
message = '标题:{0}'.format(self.title)
if self.message_time:
message = '{0}\n时间:{1}'.format(message, self.time)
if message:
message = '... | 渲染消息
:return: 渲染后的消息 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/objects.py#L105-L120 |
bluedazzle/wechat_sender | wechat_sender/listener.py | generate_run_info | def generate_run_info():
"""
获取当前运行状态
"""
uptime = datetime.datetime.now() - datetime.datetime.fromtimestamp(glb.run_info.create_time())
memory_usage = glb.run_info.memory_info().rss
msg = '[当前时间] {now:%H:%M:%S}\n[运行时间] {uptime}\n[内存占用] {memory}\n[发送消息] {messages}'.format(
now=datetime.d... | python | def generate_run_info():
"""
获取当前运行状态
"""
uptime = datetime.datetime.now() - datetime.datetime.fromtimestamp(glb.run_info.create_time())
memory_usage = glb.run_info.memory_info().rss
msg = '[当前时间] {now:%H:%M:%S}\n[运行时间] {uptime}\n[内存占用] {memory}\n[发送消息] {messages}'.format(
now=datetime.d... | 获取当前运行状态 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L216-L228 |
bluedazzle/wechat_sender | wechat_sender/listener.py | check_bot | def check_bot(task_type=SYSTEM_TASK):
"""
wxpy bot 健康检查任务
"""
if glb.wxbot.bot.alive:
msg = generate_run_info()
message = Message(content=msg, receivers='status')
glb.wxbot.send_msg(message)
_logger.info(
'{0} Send status message {1} at {2:%Y-%m-%d %H:%M:%S}'.... | python | def check_bot(task_type=SYSTEM_TASK):
"""
wxpy bot 健康检查任务
"""
if glb.wxbot.bot.alive:
msg = generate_run_info()
message = Message(content=msg, receivers='status')
glb.wxbot.send_msg(message)
_logger.info(
'{0} Send status message {1} at {2:%Y-%m-%d %H:%M:%S}'.... | wxpy bot 健康检查任务 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L231-L243 |
bluedazzle/wechat_sender | wechat_sender/listener.py | timeout_message_report | def timeout_message_report():
"""
周期/延时 消息报告
"""
timeout_list = glb.ioloop._timeouts
delay_task = []
for timeout in timeout_list:
if not timeout.callback:
continue
if len(timeout.callback.args) == 2:
task_type, message = timeout.callback.args
d... | python | def timeout_message_report():
"""
周期/延时 消息报告
"""
timeout_list = glb.ioloop._timeouts
delay_task = []
for timeout in timeout_list:
if not timeout.callback:
continue
if len(timeout.callback.args) == 2:
task_type, message = timeout.callback.args
d... | 周期/延时 消息报告 | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L246-L269 |
bluedazzle/wechat_sender | wechat_sender/listener.py | register_listener_handle | def register_listener_handle(wxbot):
"""
wechat_sender 向 wxpy 注册控制消息 handler
"""
from wxpy import TEXT
@wxbot.bot.register(wxbot.default_receiver, TEXT, except_self=False)
def sender_command_handle(msg):
command_dict = {MESSAGE_REPORT_COMMAND: timeout_message_report(),
... | python | def register_listener_handle(wxbot):
"""
wechat_sender 向 wxpy 注册控制消息 handler
"""
from wxpy import TEXT
@wxbot.bot.register(wxbot.default_receiver, TEXT, except_self=False)
def sender_command_handle(msg):
command_dict = {MESSAGE_REPORT_COMMAND: timeout_message_report(),
... | wechat_sender 向 wxpy 注册控制消息 handler | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L272-L292 |
bluedazzle/wechat_sender | wechat_sender/listener.py | listen | def listen(bot, receivers=None, token=None, port=10245, status_report=False, status_receiver=None,
status_interval=DEFAULT_REPORT_TIME):
"""
传入 bot 实例并启动 wechat_sender 服务
:param bot: (必填|Bot对象) - wxpy 的 Bot 对象实例
:param receivers: (选填|wxpy.Chat 对象|Chat 对象列表) - 消息接收者,wxpy 的 Chat 对象实例, 或 Chat 对... | python | def listen(bot, receivers=None, token=None, port=10245, status_report=False, status_receiver=None,
status_interval=DEFAULT_REPORT_TIME):
"""
传入 bot 实例并启动 wechat_sender 服务
:param bot: (必填|Bot对象) - wxpy 的 Bot 对象实例
:param receivers: (选填|wxpy.Chat 对象|Chat 对象列表) - 消息接收者,wxpy 的 Chat 对象实例, 或 Chat 对... | 传入 bot 实例并启动 wechat_sender 服务
:param bot: (必填|Bot对象) - wxpy 的 Bot 对象实例
:param receivers: (选填|wxpy.Chat 对象|Chat 对象列表) - 消息接收者,wxpy 的 Chat 对象实例, 或 Chat 对象列表,如果为 list 第一个 Chat 为默认接收者。如果为 Chat 对象,则默认接收者也是此对象。 不填为当前 bot 对象的文件接收者
:param token: (选填|str) - 信令,防止 receiver 被非法滥用,建议加上 token 防止非法使用,如果使用 token 请在初始化 `S... | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L295-L326 |
user-cont/colin | colin/core/colin.py | run | def run(
target,
target_type,
tags=None,
ruleset_name=None,
ruleset_file=None,
ruleset=None,
logging_level=logging.WARNING,
checks_paths=None,
pull=None,
insecure=False,
skips=None,
timeout=None,
):
"""
Runs the sanity checks for the target.
:param timeout: t... | python | def run(
target,
target_type,
tags=None,
ruleset_name=None,
ruleset_file=None,
ruleset=None,
logging_level=logging.WARNING,
checks_paths=None,
pull=None,
insecure=False,
skips=None,
timeout=None,
):
"""
Runs the sanity checks for the target.
:param timeout: t... | Runs the sanity checks for the target.
:param timeout: timeout per-check (in seconds)
:param skips: name of checks to skip
:param target: str (image name, ostree or dockertar)
or ImageTarget
or path/file-like object for dockerfile
:param target_type: string, eith... | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/colin.py#L26-L78 |
user-cont/colin | colin/core/colin.py | get_checks | def get_checks(
target_type=None,
tags=None,
ruleset_name=None,
ruleset_file=None,
ruleset=None,
logging_level=logging.WARNING,
checks_paths=None,
skips=None,
):
"""
Get the sanity checks for the target.
:param skips: name of checks to skip
:param target_type: TargetType... | python | def get_checks(
target_type=None,
tags=None,
ruleset_name=None,
ruleset_file=None,
ruleset=None,
logging_level=logging.WARNING,
checks_paths=None,
skips=None,
):
"""
Get the sanity checks for the target.
:param skips: name of checks to skip
:param target_type: TargetType... | Get the sanity checks for the target.
:param skips: name of checks to skip
:param target_type: TargetType enum
:param tags: list of str (if not None, the checks will be filtered by tags.)
:param ruleset_name: str (e.g. fedora; if None, default would be used)
:param ruleset_file: fileobj instance ho... | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/colin.py#L81-L114 |
user-cont/colin | colin/core/colin.py | _set_logging | def _set_logging(
logger_name="colin",
level=logging.INFO,
handler_class=logging.StreamHandler,
handler_kwargs=None,
format='%(asctime)s.%(msecs).03d %(filename)-17s %(levelname)-6s %(message)s',
date_format='%H:%M:%S'):
"""
Set personal logger for this library.
... | python | def _set_logging(
logger_name="colin",
level=logging.INFO,
handler_class=logging.StreamHandler,
handler_kwargs=None,
format='%(asctime)s.%(msecs).03d %(filename)-17s %(levelname)-6s %(message)s',
date_format='%H:%M:%S'):
"""
Set personal logger for this library.
... | Set personal logger for this library.
:param logger_name: str, name of the logger
:param level: int, see logging.{DEBUG,INFO,ERROR,...}: level of logger and handler
:param handler_class: logging.Handler instance, default is StreamHandler (/dev/stderr)
:param handler_kwargs: dict, keyword arguments to h... | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/colin.py#L135-L164 |
user-cont/colin | colin/core/checks/check_utils.py | check_label | def check_label(labels, required, value_regex, target_labels):
"""
Check if the label is required and match the regex
:param labels: [str]
:param required: bool (if the presence means pass or not)
:param value_regex: str (using search method)
:param target_labels: [str]
:return: bool (requi... | python | def check_label(labels, required, value_regex, target_labels):
"""
Check if the label is required and match the regex
:param labels: [str]
:param required: bool (if the presence means pass or not)
:param value_regex: str (using search method)
:param target_labels: [str]
:return: bool (requi... | Check if the label is required and match the regex
:param labels: [str]
:param required: bool (if the presence means pass or not)
:param value_regex: str (using search method)
:param target_labels: [str]
:return: bool (required==True: True if the label is present and match the regex if specified)
... | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/checks/check_utils.py#L7-L34 |
user-cont/colin | colin/core/checks/abstract_check.py | AbstractCheck.json | def json(self):
"""
Get json representation of the check
:return: dict (str -> obj)
"""
return {
'name': self.name,
'message': self.message,
'description': self.description,
'reference_url': self.reference_url,
'tags': ... | python | def json(self):
"""
Get json representation of the check
:return: dict (str -> obj)
"""
return {
'name': self.name,
'message': self.message,
'description': self.description,
'reference_url': self.reference_url,
'tags': ... | Get json representation of the check
:return: dict (str -> obj) | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/checks/abstract_check.py#L47-L59 |
user-cont/colin | colin/core/ruleset/ruleset.py | get_checks_paths | def get_checks_paths(checks_paths=None):
"""
Get path to checks.
:param checks_paths: list of str, directories where the checks are present
:return: list of str (absolute path of directory with checks)
"""
p = os.path.join(__file__, os.pardir, os.pardir, os.pardir, "checks")
p = os.path.abs... | python | def get_checks_paths(checks_paths=None):
"""
Get path to checks.
:param checks_paths: list of str, directories where the checks are present
:return: list of str (absolute path of directory with checks)
"""
p = os.path.join(__file__, os.pardir, os.pardir, os.pardir, "checks")
p = os.path.abs... | Get path to checks.
:param checks_paths: list of str, directories where the checks are present
:return: list of str (absolute path of directory with checks) | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/ruleset.py#L124-L136 |
user-cont/colin | colin/core/ruleset/ruleset.py | get_ruleset_file | def get_ruleset_file(ruleset=None):
"""
Get the ruleset file from name
:param ruleset: str
:return: str
"""
ruleset = ruleset or "default"
ruleset_dirs = get_ruleset_dirs()
for ruleset_directory in ruleset_dirs:
possible_ruleset_files = [os.path.join(ruleset_directory, ruleset ... | python | def get_ruleset_file(ruleset=None):
"""
Get the ruleset file from name
:param ruleset: str
:return: str
"""
ruleset = ruleset or "default"
ruleset_dirs = get_ruleset_dirs()
for ruleset_directory in ruleset_dirs:
possible_ruleset_files = [os.path.join(ruleset_directory, ruleset ... | Get the ruleset file from name
:param ruleset: str
:return: str | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/ruleset.py#L139-L159 |
user-cont/colin | colin/core/ruleset/ruleset.py | get_ruleset_dirs | def get_ruleset_dirs():
"""
Get the directory with ruleset files
First directory to check: ./rulesets
Second directory to check: $HOME/.local/share/colin/rulesets
Third directory to check: /usr/local/share/colin/rulesets
:return: str
"""
ruleset_dirs = []
cwd_rulesets = os.path.j... | python | def get_ruleset_dirs():
"""
Get the directory with ruleset files
First directory to check: ./rulesets
Second directory to check: $HOME/.local/share/colin/rulesets
Third directory to check: /usr/local/share/colin/rulesets
:return: str
"""
ruleset_dirs = []
cwd_rulesets = os.path.j... | Get the directory with ruleset files
First directory to check: ./rulesets
Second directory to check: $HOME/.local/share/colin/rulesets
Third directory to check: /usr/local/share/colin/rulesets
:return: str | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/ruleset.py#L162-L202 |
user-cont/colin | colin/core/ruleset/ruleset.py | get_rulesets | def get_rulesets():
""""
Get available rulesets.
"""
rulesets_dirs = get_ruleset_dirs()
ruleset_files = []
for rulesets_dir in rulesets_dirs:
for f in os.listdir(rulesets_dir):
for ext in EXTS:
file_path = os.path.join(rulesets_dir, f)
if os.pa... | python | def get_rulesets():
""""
Get available rulesets.
"""
rulesets_dirs = get_ruleset_dirs()
ruleset_files = []
for rulesets_dir in rulesets_dirs:
for f in os.listdir(rulesets_dir):
for ext in EXTS:
file_path = os.path.join(rulesets_dir, f)
if os.pa... | Get available rulesets. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/ruleset.py#L205-L217 |
user-cont/colin | colin/core/ruleset/ruleset.py | Ruleset.get_checks | def get_checks(self, target_type, tags=None, skips=None):
"""
Get all checks for given type/tags.
:param skips: list of str
:param target_type: TargetType class
:param tags: list of str
:return: list of check instances
"""
skips = skips or []
resu... | python | def get_checks(self, target_type, tags=None, skips=None):
"""
Get all checks for given type/tags.
:param skips: list of str
:param target_type: TargetType class
:param tags: list of str
:return: list of check instances
"""
skips = skips or []
resu... | Get all checks for given type/tags.
:param skips: list of str
:param target_type: TargetType class
:param tags: list of str
:return: list of check instances | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/ruleset.py#L56-L121 |
user-cont/colin | colin/utils/cmd_tools.py | get_version_msg_from_the_cmd | def get_version_msg_from_the_cmd(package_name, cmd=None, use_rpm=None,
max_lines_of_the_output=None):
"""
Get str with the version (or string representation of the error).
:param package_name: str
:param cmd: str or [str] (defaults to [package_name, "--version"])
:p... | python | def get_version_msg_from_the_cmd(package_name, cmd=None, use_rpm=None,
max_lines_of_the_output=None):
"""
Get str with the version (or string representation of the error).
:param package_name: str
:param cmd: str or [str] (defaults to [package_name, "--version"])
:p... | Get str with the version (or string representation of the error).
:param package_name: str
:param cmd: str or [str] (defaults to [package_name, "--version"])
:param use_rpm: True/False/None (whether to use rpm -q for getting a version)
:param max_lines_of_the_output: use first n lines of the output
... | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L42-L74 |
user-cont/colin | colin/utils/cmd_tools.py | get_rpm_version | def get_rpm_version(package_name):
"""Get a version of the package with 'rpm -q' command."""
version_result = subprocess.run(["rpm", "-q", package_name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if version_result.returncode == 0:... | python | def get_rpm_version(package_name):
"""Get a version of the package with 'rpm -q' command."""
version_result = subprocess.run(["rpm", "-q", package_name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if version_result.returncode == 0:... | Get a version of the package with 'rpm -q' command. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L77-L85 |
user-cont/colin | colin/utils/cmd_tools.py | is_rpm_installed | def is_rpm_installed():
"""Tests if the rpm command is present."""
try:
version_result = subprocess.run(["rpm", "--usage"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
rpm_installed = not version_result.returncod... | python | def is_rpm_installed():
"""Tests if the rpm command is present."""
try:
version_result = subprocess.run(["rpm", "--usage"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
rpm_installed = not version_result.returncod... | Tests if the rpm command is present. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L88-L97 |
user-cont/colin | colin/utils/cmd_tools.py | exit_after | def exit_after(s):
"""
Use as decorator to exit process if
function takes longer than s seconds.
Direct call is available via exit_after(TIMEOUT_IN_S)(fce)(args).
Inspired by https://stackoverflow.com/a/31667005
"""
def outer(fn):
def inner(*args, **kwargs):
timer = th... | python | def exit_after(s):
"""
Use as decorator to exit process if
function takes longer than s seconds.
Direct call is available via exit_after(TIMEOUT_IN_S)(fce)(args).
Inspired by https://stackoverflow.com/a/31667005
"""
def outer(fn):
def inner(*args, **kwargs):
timer = th... | Use as decorator to exit process if
function takes longer than s seconds.
Direct call is available via exit_after(TIMEOUT_IN_S)(fce)(args).
Inspired by https://stackoverflow.com/a/31667005 | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L100-L124 |
user-cont/colin | colin/utils/cmd_tools.py | retry | def retry(retry_count=5, delay=2):
"""
Use as decorator to retry functions few times with delays
Exception will be raised if last call fails
:param retry_count: int could of retries in case of failures. It must be
a positive number
:param delay: int delay between retries
... | python | def retry(retry_count=5, delay=2):
"""
Use as decorator to retry functions few times with delays
Exception will be raised if last call fails
:param retry_count: int could of retries in case of failures. It must be
a positive number
:param delay: int delay between retries
... | Use as decorator to retry functions few times with delays
Exception will be raised if last call fails
:param retry_count: int could of retries in case of failures. It must be
a positive number
:param delay: int delay between retries | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L127-L151 |
user-cont/colin | colin/utils/cont.py | ImageName.parse | def parse(cls, image_name):
"""
Get the instance of ImageName from the string representation.
:param image_name: str (any possible form of image name)
:return: ImageName instance
"""
result = cls()
# registry.org/namespace/repo:tag
s = image_name.split('... | python | def parse(cls, image_name):
"""
Get the instance of ImageName from the string representation.
:param image_name: str (any possible form of image name)
:return: ImageName instance
"""
result = cls()
# registry.org/namespace/repo:tag
s = image_name.split('... | Get the instance of ImageName from the string representation.
:param image_name: str (any possible form of image name)
:return: ImageName instance | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cont.py#L22-L52 |
user-cont/colin | colin/utils/cont.py | ImageName.name | def name(self):
"""
Get the string representation of the image
(registry, namespace, repository and digest together).
:return: str
"""
name_parts = []
if self.registry:
name_parts.append(self.registry)
if self.namespace:
name_part... | python | def name(self):
"""
Get the string representation of the image
(registry, namespace, repository and digest together).
:return: str
"""
name_parts = []
if self.registry:
name_parts.append(self.registry)
if self.namespace:
name_part... | Get the string representation of the image
(registry, namespace, repository and digest together).
:return: str | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cont.py#L63-L86 |
user-cont/colin | colin/core/ruleset/loader.py | nicer_get | def nicer_get(di, required, *path):
"""
this is a nicer way of doing dict.get()
:param di: dict
:param required: bool, raises an exc if value is not found, otherwise returns None
:param path: list of str to navigate in the dict
:return: your value
"""
r = di
for p in path:
... | python | def nicer_get(di, required, *path):
"""
this is a nicer way of doing dict.get()
:param di: dict
:param required: bool, raises an exc if value is not found, otherwise returns None
:param path: list of str to navigate in the dict
:return: your value
"""
r = di
for p in path:
... | this is a nicer way of doing dict.get()
:param di: dict
:param required: bool, raises an exc if value is not found, otherwise returns None
:param path: list of str to navigate in the dict
:return: your value | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/loader.py#L51-L72 |
user-cont/colin | colin/core/ruleset/loader.py | CheckStruct.other_attributes | def other_attributes(self):
""" return dict with all other data except for the described above"""
return {k: v for k, v in self.c.items() if
k not in ["name", "names", "tags", "additional_tags", "usable_targets"]} | python | def other_attributes(self):
""" return dict with all other data except for the described above"""
return {k: v for k, v in self.c.items() if
k not in ["name", "names", "tags", "additional_tags", "usable_targets"]} | return dict with all other data except for the described above | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/ruleset/loader.py#L118-L121 |
user-cont/colin | colin/core/loader.py | should_we_load | def should_we_load(kls):
""" should we load this class as a check? """
# we don't load abstract classes
if kls.__name__.endswith("AbstractCheck"):
return False
# and we only load checks
if not kls.__name__.endswith("Check"):
return False
mro = kls.__mro__
# and the class need... | python | def should_we_load(kls):
""" should we load this class as a check? """
# we don't load abstract classes
if kls.__name__.endswith("AbstractCheck"):
return False
# and we only load checks
if not kls.__name__.endswith("Check"):
return False
mro = kls.__mro__
# and the class need... | should we load this class as a check? | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/loader.py#L54-L67 |
user-cont/colin | colin/core/loader.py | CheckLoader.obtain_check_classes | def obtain_check_classes(self):
""" find children of AbstractCheck class and return them as a list """
check_classes = set()
for path in self.paths:
for root, _, files in os.walk(path):
for fi in files:
if not fi.endswith(".py"):
... | python | def obtain_check_classes(self):
""" find children of AbstractCheck class and return them as a list """
check_classes = set()
for path in self.paths:
for root, _, files in os.walk(path):
for fi in files:
if not fi.endswith(".py"):
... | find children of AbstractCheck class and return them as a list | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/loader.py#L103-L114 |
user-cont/colin | colin/core/loader.py | CheckLoader.import_class | def import_class(self, import_name):
"""
import selected class
:param import_name, str, e.g. some.module.MyClass
:return the class
"""
module_name, class_name = import_name.rsplit(".", 1)
mod = import_module(module_name)
check_class = getattr(mod, class_n... | python | def import_class(self, import_name):
"""
import selected class
:param import_name, str, e.g. some.module.MyClass
:return the class
"""
module_name, class_name = import_name.rsplit(".", 1)
mod = import_module(module_name)
check_class = getattr(mod, class_n... | import selected class
:param import_name, str, e.g. some.module.MyClass
:return the class | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/loader.py#L116-L128 |
user-cont/colin | colin/core/result.py | CheckResults._dict_of_results | def _dict_of_results(self):
"""
Get the dictionary representation of results
:return: dict (str -> dict (str -> str))
"""
result_json = {}
result_list = []
for r in self.results:
result_list.append({
'name': r.check_name,
... | python | def _dict_of_results(self):
"""
Get the dictionary representation of results
:return: dict (str -> dict (str -> str))
"""
result_json = {}
result_list = []
for r in self.results:
result_list.append({
'name': r.check_name,
... | Get the dictionary representation of results
:return: dict (str -> dict (str -> str)) | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/result.py#L64-L84 |
user-cont/colin | colin/core/result.py | CheckResults.statistics | def statistics(self):
"""
Get the dictionary with the count of the check-statuses
:return: dict(str -> int)
"""
result = {}
for r in self.results:
result.setdefault(r.status, 0)
result[r.status] += 1
return result | python | def statistics(self):
"""
Get the dictionary with the count of the check-statuses
:return: dict(str -> int)
"""
result = {}
for r in self.results:
result.setdefault(r.status, 0)
result[r.status] += 1
return result | Get the dictionary with the count of the check-statuses
:return: dict(str -> int) | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/result.py#L101-L111 |
user-cont/colin | colin/core/result.py | CheckResults.generate_pretty_output | def generate_pretty_output(self, stat, verbose, output_function, logs=True):
"""
Send the formated to the provided function
:param stat: if True print stat instead of full output
:param verbose: bool
:param output_function: function to send output to
"""
has_che... | python | def generate_pretty_output(self, stat, verbose, output_function, logs=True):
"""
Send the formated to the provided function
:param stat: if True print stat instead of full output
:param verbose: bool
:param output_function: function to send output to
"""
has_che... | Send the formated to the provided function
:param stat: if True print stat instead of full output
:param verbose: bool
:param output_function: function to send output to | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/result.py#L133-L171 |
user-cont/colin | colin/core/result.py | CheckResults.get_pretty_string | def get_pretty_string(self, stat, verbose):
"""
Pretty string representation of the results
:param stat: bool
:param verbose: bool
:return: str
"""
pretty_output = _PrettyOutputToStr()
self.generate_pretty_output(stat=stat,
... | python | def get_pretty_string(self, stat, verbose):
"""
Pretty string representation of the results
:param stat: bool
:param verbose: bool
:return: str
"""
pretty_output = _PrettyOutputToStr()
self.generate_pretty_output(stat=stat,
... | Pretty string representation of the results
:param stat: bool
:param verbose: bool
:return: str | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/result.py#L173-L185 |
user-cont/colin | colin/core/checks/fmf_check.py | receive_fmf_metadata | def receive_fmf_metadata(name, path, object_list=False):
"""
search node identified by name fmfpath
:param path: path to filesystem
:param name: str - name as pattern to search - "/name" (prepended hierarchy item)
:param object_list: bool, if true, return whole list of found items
:return: Tree... | python | def receive_fmf_metadata(name, path, object_list=False):
"""
search node identified by name fmfpath
:param path: path to filesystem
:param name: str - name as pattern to search - "/name" (prepended hierarchy item)
:param object_list: bool, if true, return whole list of found items
:return: Tree... | search node identified by name fmfpath
:param path: path to filesystem
:param name: str - name as pattern to search - "/name" (prepended hierarchy item)
:param object_list: bool, if true, return whole list of found items
:return: Tree Object or list | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/checks/fmf_check.py#L15-L38 |
user-cont/colin | colin/cli/colin.py | check | def check(target, ruleset, ruleset_file, debug, json, stat, skip, tag, verbose,
checks_paths, target_type, timeout, pull, insecure):
"""
Check the image/dockerfile (default).
"""
if ruleset and ruleset_file:
raise click.BadOptionUsage(
"Options '--ruleset' and '--file-rules... | python | def check(target, ruleset, ruleset_file, debug, json, stat, skip, tag, verbose,
checks_paths, target_type, timeout, pull, insecure):
"""
Check the image/dockerfile (default).
"""
if ruleset and ruleset_file:
raise click.BadOptionUsage(
"Options '--ruleset' and '--file-rules... | Check the image/dockerfile (default). | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L81-L134 |
user-cont/colin | colin/cli/colin.py | list_checks | def list_checks(ruleset, ruleset_file, debug, json, skip, tag, verbose, checks_paths):
"""
Print the checks.
"""
if ruleset and ruleset_file:
raise click.BadOptionUsage(
"Options '--ruleset' and '--file-ruleset' cannot be used together.")
try:
if not debug:
l... | python | def list_checks(ruleset, ruleset_file, debug, json, skip, tag, verbose, checks_paths):
"""
Print the checks.
"""
if ruleset and ruleset_file:
raise click.BadOptionUsage(
"Options '--ruleset' and '--file-ruleset' cannot be used together.")
try:
if not debug:
l... | Print the checks. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L158-L193 |
user-cont/colin | colin/cli/colin.py | list_rulesets | def list_rulesets(debug):
"""
List available rulesets.
"""
try:
rulesets = get_rulesets()
max_len = max([len(r[0]) for r in rulesets])
for r in rulesets:
click.echo('{0: <{1}} ({2})'.format(r[0], max_len, r[1]))
except Exception as ex:
logger.error("An err... | python | def list_rulesets(debug):
"""
List available rulesets.
"""
try:
rulesets = get_rulesets()
max_len = max([len(r[0]) for r in rulesets])
for r in rulesets:
click.echo('{0: <{1}} ({2})'.format(r[0], max_len, r[1]))
except Exception as ex:
logger.error("An err... | List available rulesets. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L200-L214 |
user-cont/colin | colin/cli/colin.py | info | def info():
"""
Show info about colin and its dependencies.
"""
installation_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
click.echo("colin {} {}".format(__version__, installation_path))
click.echo("colin-cli {}\n".format(os.path.realpath(__file__)))
# cl... | python | def info():
"""
Show info about colin and its dependencies.
"""
installation_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
click.echo("colin {} {}".format(__version__, installation_path))
click.echo("colin-cli {}\n".format(os.path.realpath(__file__)))
# cl... | Show info about colin and its dependencies. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L219-L235 |
user-cont/colin | colin/cli/colin.py | _print_results | def _print_results(results, stat=False, verbose=False):
"""
Prints the results to the stdout
:type verbose: bool
:param results: generator of results
:param stat: if True print stat instead of full output
"""
results.generate_pretty_output(stat=stat,
verbo... | python | def _print_results(results, stat=False, verbose=False):
"""
Prints the results to the stdout
:type verbose: bool
:param results: generator of results
:param stat: if True print stat instead of full output
"""
results.generate_pretty_output(stat=stat,
verbo... | Prints the results to the stdout
:type verbose: bool
:param results: generator of results
:param stat: if True print stat instead of full output | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L245-L255 |
user-cont/colin | colin/core/target.py | inspect_object | def inspect_object(obj, refresh=True):
"""
inspect provided object (container, image) and return raw dict with the metadata
:param obj: instance of Container or an Image
:param refresh: bool, refresh the metadata or return cached?
:return: dict
"""
if hasattr(obj, "inspect"):
return... | python | def inspect_object(obj, refresh=True):
"""
inspect provided object (container, image) and return raw dict with the metadata
:param obj: instance of Container or an Image
:param refresh: bool, refresh the metadata or return cached?
:return: dict
"""
if hasattr(obj, "inspect"):
return... | inspect provided object (container, image) and return raw dict with the metadata
:param obj: instance of Container or an Image
:param refresh: bool, refresh the metadata or return cached?
:return: dict | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L50-L60 |
user-cont/colin | colin/core/target.py | Target.get_instance | def get_instance(target_type, **kwargs):
"""
:param target_type: string, either image, dockertar, ostree or dockerfile
"""
if target_type in TARGET_TYPES:
cls = TARGET_TYPES[target_type]
try:
return cls(**kwargs)
except Exception:
... | python | def get_instance(target_type, **kwargs):
"""
:param target_type: string, either image, dockertar, ostree or dockerfile
"""
if target_type in TARGET_TYPES:
cls = TARGET_TYPES[target_type]
try:
return cls(**kwargs)
except Exception:
... | :param target_type: string, either image, dockertar, ostree or dockerfile | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L99-L114 |
user-cont/colin | colin/core/target.py | DockerfileTarget.labels | def labels(self):
"""
Get list of labels from the target instance.
:return: [str]
"""
if self._labels is None:
self._labels = self.instance.labels
return self._labels | python | def labels(self):
"""
Get list of labels from the target instance.
:return: [str]
"""
if self._labels is None:
self._labels = self.instance.labels
return self._labels | Get list of labels from the target instance.
:return: [str] | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L131-L139 |
user-cont/colin | colin/core/target.py | AbstractImageTarget.read_file | def read_file(self, file_path):
"""
read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file
"""
try:
... | python | def read_file(self, file_path):
"""
read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file
"""
try:
... | read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L169-L182 |
user-cont/colin | colin/core/target.py | AbstractImageTarget.get_file | def get_file(self, file_path, mode="r"):
"""
provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance
"""
return open(self.cont_path(file_path), mode=mode) | python | def get_file(self, file_path, mode="r"):
"""
provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance
"""
return open(self.cont_path(file_path), mode=mode) | provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L184-L191 |
user-cont/colin | colin/core/target.py | AbstractImageTarget.file_is_present | def file_is_present(self, file_path):
"""
check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist
"""
real_path = self.cont_path(file_path)
... | python | def file_is_present(self, file_path):
"""
check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist
"""
real_path = self.cont_path(file_path)
... | check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L193-L205 |
user-cont/colin | colin/core/target.py | AbstractImageTarget.cont_path | def cont_path(self, path):
"""
provide absolute path within the container
:param path: path with container
:return: str
"""
if path.startswith("/"):
path = path[1:]
real_path = os.path.join(self.mount_point, path)
logger.debug("path = %s", rea... | python | def cont_path(self, path):
"""
provide absolute path within the container
:param path: path with container
:return: str
"""
if path.startswith("/"):
path = path[1:]
real_path = os.path.join(self.mount_point, path)
logger.debug("path = %s", rea... | provide absolute path within the container
:param path: path with container
:return: str | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L207-L218 |
user-cont/colin | colin/core/target.py | ImageTarget.mount_point | def mount_point(self):
""" podman mount -- real filesystem """
if self._mount_point is None:
cmd_create = ["podman", "create", self.target_name, "some-cmd"]
self._mounted_container_id = subprocess.check_output(cmd_create).decode().rstrip()
cmd_mount = ["podman", "moun... | python | def mount_point(self):
""" podman mount -- real filesystem """
if self._mount_point is None:
cmd_create = ["podman", "create", self.target_name, "some-cmd"]
self._mounted_container_id = subprocess.check_output(cmd_create).decode().rstrip()
cmd_mount = ["podman", "moun... | podman mount -- real filesystem | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L264-L271 |
user-cont/colin | colin/core/target.py | OstreeTarget.labels | def labels(self):
"""
Provide labels without the need of dockerd. Instead skopeo is being used.
:return: dict
"""
if self._labels is None:
cmd = ["skopeo", "inspect", self.skopeo_target]
self._labels = json.loads(subprocess.check_output(cmd))["Labels"]
... | python | def labels(self):
"""
Provide labels without the need of dockerd. Instead skopeo is being used.
:return: dict
"""
if self._labels is None:
cmd = ["skopeo", "inspect", self.skopeo_target]
self._labels = json.loads(subprocess.check_output(cmd))["Labels"]
... | Provide labels without the need of dockerd. Instead skopeo is being used.
:return: dict | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L341-L350 |
user-cont/colin | colin/core/target.py | OstreeTarget.layers_path | def layers_path(self):
""" Directory with all the layers (docker save). """
if self._layers_path is None:
self._layers_path = os.path.join(self.tmpdir, "layers")
return self._layers_path | python | def layers_path(self):
""" Directory with all the layers (docker save). """
if self._layers_path is None:
self._layers_path = os.path.join(self.tmpdir, "layers")
return self._layers_path | Directory with all the layers (docker save). | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L353-L357 |
user-cont/colin | colin/core/target.py | OstreeTarget.mount_point | def mount_point(self):
""" ostree checkout -- real filesystem """
if self._mount_point is None:
self._mount_point = os.path.join(self.tmpdir, "checkout")
os.makedirs(self._mount_point)
self._checkout()
return self._mount_point | python | def mount_point(self):
""" ostree checkout -- real filesystem """
if self._mount_point is None:
self._mount_point = os.path.join(self.tmpdir, "checkout")
os.makedirs(self._mount_point)
self._checkout()
return self._mount_point | ostree checkout -- real filesystem | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L360-L366 |
user-cont/colin | colin/core/target.py | OstreeTarget.ostree_path | def ostree_path(self):
""" ostree repository -- content """
if self._ostree_path is None:
self._ostree_path = os.path.join(self.tmpdir, "ostree-repo")
subprocess.check_call(["ostree", "init", "--mode", "bare-user-only",
"--repo", self._ostree_pa... | python | def ostree_path(self):
""" ostree repository -- content """
if self._ostree_path is None:
self._ostree_path = os.path.join(self.tmpdir, "ostree-repo")
subprocess.check_call(["ostree", "init", "--mode", "bare-user-only",
"--repo", self._ostree_pa... | ostree repository -- content | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L369-L375 |
user-cont/colin | colin/core/target.py | OstreeTarget.tmpdir | def tmpdir(self):
""" Temporary directory holding all the runtime data. """
if self._tmpdir is None:
self._tmpdir = mkdtemp(prefix="colin-", dir="/var/tmp")
return self._tmpdir | python | def tmpdir(self):
""" Temporary directory holding all the runtime data. """
if self._tmpdir is None:
self._tmpdir = mkdtemp(prefix="colin-", dir="/var/tmp")
return self._tmpdir | Temporary directory holding all the runtime data. | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L383-L387 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.