prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>p144.py<|end_file_name|><|fim▁begin|>inside = lambda x, y: 4*x*x+y*y <= 100 def coll(sx, sy, dx, dy): m = 0 for p in range(32): m2 = m + 2**(-p) if inside(sx + dx * m2, sy + dy * m2): m = m2 return (sx + dx*m, sy + dy*m) def <|fim_middle|>(x, y): l = (x*x + y*y)**0.5 r...
norm
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path)<|fim▁hole|> " kernel: %s\n" " args: %s\n" " initrd: %...
def __repr__(self): return ("title: %s\n" " root: %s\n"
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): <|fim_middle|> class LiloConfigFile(object): def __init__(self, fn = None): self.filename = fn self.images = [] self.timeout = -1 ...
def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" " kernel: %s\n" " args: %s\n" " initrd: %s\n" %(self.title, self.root, self.kernel, ...
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): <|fim_middle|> def __repr__(self): return ("title: %s\n" " root: %s\n" " kernel...
self.reset(lines, path)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): <|fim_middle|> def reset(self, lines, path): self._initrd...
return ("title: %s\n" " root: %s\n" " kernel: %s\n" " args: %s\n" " initrd: %s\n" %(self.title, self.root, self.kernel, self.args, self.initrd))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._initrd = self._kernel = self._readonly = None self._args = "" self.title = "" self.lines = [] self.path = path self.root = "" map(self.set_from_line, lines)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
(com, arg) = GrubConf.grub_exact_split(line, 2) if self.commands.has_key(com): if self.commands[com] is not None: setattr(self, self.commands[com], re.sub('^"(.+)"$', r"\1", arg.strip())) else: logging.info("Ignored image directive %s" %(com,)) ...
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._kernel = (None, self.path + "/" + val)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
return self._kernel
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._initrd = (None, self.path + "/" + val)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
return self._initrd
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._args = val
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
args = self._args if self.root: args += " root=" + self.root if self.readonly: args += " ro" return args
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._readonly = 1
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
return self._readonly
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
def __init__(self, fn = None): self.filename = fn self.images = [] self.timeout = -1 self._default = 0 if fn is not None: self.parse() def parse(self, buf = None): if buf is None: if self.filename is None: raise ValueError...
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.filename = fn self.images = [] self.timeout = -1 self._default = 0 if fn is not None: self.parse()
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if buf is None: if self.filename is None: raise ValueError, "No config file defined to parse!" f = open(self.filename, 'r') lines = f.readlines() f.close() else: lines = buf.split("\n") path = os.path.dirname(self.file...
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.images.append(image)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
for i in range(0, len(self.images) - 1): if self.images[i].title == self._default: return i return 0
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self._default = val
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if self.commands[com] is not None: setattr(self, self.commands[com], re.sub('^"(.+)"$', r"\1", arg.strip())) else: logging.info("Ignored image directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
setattr(self, self.commands[com], re.sub('^"(.+)"$', r"\1", arg.strip()))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
logging.info("Ignored image directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
logging.warning("Unknown image directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.lines.append(line)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.lines.pop(replace) self.lines.insert(replace, line)
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
args += " root=" + self.root
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
args += " ro"
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.parse()
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if self.filename is None: raise ValueError, "No config file defined to parse!" f = open(self.filename, 'r') lines = f.readlines() f.close()
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
raise ValueError, "No config file defined to parse!"
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
lines = buf.split("\n")
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
continue
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
continue
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if len(img) > 0: self.add_image(LiloImage(img, path)) img = [l] continue
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.add_image(LiloImage(img, path))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
img.append(l) continue
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if self.commands[com] is not None: setattr(self, self.commands[com], arg.strip()) else: logging.info("Ignored directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
setattr(self, self.commands[com], arg.strip())
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
logging.info("Ignored directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
logging.warning("Unknown directive %s" %(com,))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
self.add_image(LiloImage(img, path))
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
return i
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
if sys.argv < 2: raise RuntimeError, "Need a grub.conf to read" g = LiloConfigFile(sys.argv[1]) for i in g.images: print i #, i.title, i.root, i.kernel, i.args, i.initrd print g.default
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
raise RuntimeError, "Need a grub.conf to read"
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def <|fim_middle|>(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" ...
__init__
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def <|fim_middle|>(self): return ("title: %s\n" " root: %s\n" ...
__repr__
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
reset
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
set_from_line
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
set_kernel
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
get_kernel
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
set_initrd
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
get_initrd
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
set_args
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
get_args
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
set_readonly
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
get_readonly
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
__init__
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
parse
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
add_image
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
_get_default
<|file_name|>LiloConf.py<|end_file_name|><|fim▁begin|># #LiloConf.py # import sys, re, os import logging import GrubConf class LiloImage(object): def __init__(self, lines, path): self.reset(lines, path) def __repr__(self): return ("title: %s\n" " root: %s\n" "...
_set_default
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
if token == "'": if processed % 2 == 0 and (i == 0 or processed != count - 1): tokens[i] = "`" processed += 1
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): <|fim_middle|> def balance_quotes(tokens): count = tokens.count("'") if not count: return processed = 0 for i, token in enumerate(tokens): if token == "'": if processed % 2 == 0 an...
if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.')
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): <|fim_middle|> def...
count = tokens.count("'") if not count: return processed = 0 for i, token in enumerate(tokens): if token == "'": if processed % 2 == 0 and (i == 0 or processed != count - 1): tokens[i] = "`" processed += 1
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
if not tokens: return # fix_terminator(tokens) balance_quotes(tokens) print ' '.join(tokens)
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: <|fim_middle|> last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count =...
return
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): <|fim_middle|> def balance_quotes(tokens): count = tokens.count("'") if not count: ...
tokens[-1] = last[:-1] tokens.append('.')
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
return
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
if processed % 2 == 0 and (i == 0 or processed != count - 1): tokens[i] = "`" processed += 1
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
tokens[i] = "`"
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
return
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
prev.append(tokens[0])
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
output(prev) prev = tokens
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def <|fim_middle|>(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
fix_terminator
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def <|fim_middle|>(tokens): count = tokens.count...
balance_quotes
<|file_name|>fixes.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys def fix_terminator(tokens): if not tokens: return last = tokens[-1] if last not in ('.', '?', '!') and last.endswith('.'): tokens[-1] = last[:-1] tokens.append('.') def balance_quotes(tokens): count = tokens.count...
output
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines):<|fim▁hole|> points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): <|fim_middle|> def corrupted_character(inp): stack = [] lookup = {'(': ')', '[': ']', '{': '}', '<': '>'} lookup_close = {v: k for k, v in lookup.items()} def stack_converter(st): ...
points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: s += points[corrupted] else: scores_auto.append(score_autocomplete(stack)) return s, sorte...
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
stack = [] lookup = {'(': ')', '[': ']', '{': '}', '<': '>'} lookup_close = {v: k for k, v in lookup.items()} def stack_converter(st): return [lookup[element] for element in st[::-1]] for char in inp: if char in lookup: stack.append(char) elif char in lookup_clo...
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
return [lookup[element] for element in st[::-1]]
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
points_autocomplete = {')': 1, ']': 2, '}': 3, '>': 4} s_auto = 0 for char in stack: s_auto *= 5 s_auto += points_autocomplete[char] return s_auto
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
assert corrupted_character('{([(<{}[<>[]}>{[]{[(<()>')[0] == '}' assert corrupted_character('[[<[([]))<([[{}[[()]]]')[0] == ')' assert corrupted_character('[{[{({}]{}}([{[{{{}}([]')[0] == ']' assert corrupted_character('[<(<(<(<{}))><([]([]()')[0] == ')' assert corrupted_character('<{([([[(<>()){}]>...
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
assert score_syntax_errors(open('input/10.test').read().splitlines()) == (26397, 288957)
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
assert corrupted_character('[({(<(())[]>[[{[]{<()<>>')[1] == ['}', '}', ']', ']', ')', '}', ')', ']']
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
assert score_autocomplete('}}]])})]') == 288957 assert score_autocomplete(')}>]})') == 5566 assert score_autocomplete('}}>}>))))') == 1480781
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
s += points[corrupted]
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
scores_auto.append(score_autocomplete(stack))
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
stack.append(char)
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
expected = stack.pop() if expected != lookup_close[char]: return char, stack_converter(stack)
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
return char, stack_converter(stack)
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
print(f"INVALID {char}")
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
print(score_syntax_errors(open('input/10').read().splitlines()))
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def <|fim_middle|>(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: s +=...
score_syntax_errors
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
corrupted_character
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
stack_converter
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
score_autocomplete
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
test_corrupted_character
<|file_name|>day10.py<|end_file_name|><|fim▁begin|>from math import floor def score_syntax_errors(program_lines): points = {')': 3, ']': 57, '}': 1197, '>': 25137} s = 0 scores_auto = [] for line in program_lines: corrupted, stack = corrupted_character(line) if corrupted: ...
test_score_syntax_errors