Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
key = key.replace('_', '-')
current.append('%s: %s' % (key, value))
tag.set('style', '; '.join(current))
elif isinstance(value, basestring):
attr = attr.replace('_', '-')
for tag in self:
current = [
el.strip()
for el in (tag.get('style') or '').split(';')
if (el.strip() and
not el.split(':')[0].strip() == attr.strip())]
current.append('%s: %s' % (attr, value))
tag.set('style', '; '.join(current))
return self
css = FlexibleElement(pget=css, pset=css)
###################
# CORE UI EFFECTS #
###################
def hide(self):
"""Remove display:none to elements style:
>>> print(PyQuery('<div style="display:none;">').hide())
<div style="display: none">
"""
return self.css('display', 'none')
def show(self):
"""Add display:block to elements style:
</div></div>
for key, value in attr.items():
key = key.replace('_', '-')
current.append('%s: %s' % (key, value))
tag.set('style', '; '.join(current))
elif isinstance(value, basestring):
attr = attr.replace('_', '-')
for tag in self:
current = [el.strip()
for el in (tag.get('style') or '').split(';')
if el.strip()
and not el.split(':')[0].strip() == attr.strip()]
current.append('%s: %s' % (attr, value))
tag.set('style', '; '.join(current))
return self
css = FlexibleElement(pget=css, pset=css)
###################
# CORE UI EFFECTS #
###################
def hide(self):
"""remove display:none to elements style
>>> print(PyQuery('<div style="display:none;">').hide())
<div style="display: none">
"""
return self.css('display', 'none')
def show(self):
"""add display:block to elements style
</div></div>
return self
def removeAttr(self, name):
"""Remove an attribute::
>>> d = PyQuery('<div id="myid"></div>')
>>> d.removeAttr('id')
[<div>]
..
"""
for tag in self:
del tag.attrib[name]
return self
attr = FlexibleElement(pget=attr, pdel=removeAttr)
#######
# CSS #
#######
def height(self, value=no_default):
"""set/get height of element
"""
return self.attr('height', value)
def width(self, value=no_default):
"""set/get width of element
"""
return self.attr('width', value)
def hasClass(self, name):
"""Return True if element has class::</div>
>>> d = PyQuery('<div id="myid"></div>')
>>> d.remove_attr('id')
[<div>]
>>> d.removeAttr('id')
[<div>]
..
"""
for tag in self:
try:
del tag.attrib[name]
except KeyError:
pass
return self
attr = FlexibleElement(pget=attr, pdel=remove_attr)
#######
# CSS #
#######
def height(self, value=no_default):
"""set/get height of element
"""
return self.attr('height', value)
def width(self, value=no_default):
"""set/get width of element
"""
return self.attr('width', value)
@with_camel_case_alias
def has_class(self, name):</div></div>