Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def timestamp(self, value):
if value is not None and value is not False:
if not isinstance(value, six.string_types):
value = java_timestamp(value)
comments = [
Comment(c) for c in ascii_splitlines(to_comment(value) + '\n')
]
else:
comments = []
for n in self._lines.iternodes():
if isinstance(n.value, Comment) and n.value.is_timestamp():
if comments:
n.value = comments[0]
for c in comments[1:]:
n = n.insert_after(c)
else:
n.unlink()
return
elif isinstance(n.value, KeyValue):
for c in comments:
n.insert_before(c)
return
def header_comment(self, value):
if value is None:
comments = []
else:
comments = [
Comment(c) for c in ascii_splitlines(to_comment(value) + '\n')
]
while self._lines.start is not None:
n = self._lines.start
if isinstance(n.value, KeyValue) or \
(isinstance(n.value, Comment) and n.value.is_timestamp()):
break
else:
n.unlink()
if self._lines.start is None:
for c in comments:
self._lines.append(c)
else:
n = self._lines.start
for c in comments:
n.insert_before(c)