Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line after this snippet: <|code_start|># Various HTTP calls against HTTPBin
def test_get_graph(url, query_params):
http_params = dict(url=url, query=query_params, mime_type='application/json',
verify_ssl=False)
v = value.Value(value=url)
h = http.Get(**http_params)... | g.connect(h, post_data, 'post_data') |
Predict the next line for this snippet: <|code_start|> v = value.Value(value=url)
post_data = value.Value(value=post_data)
h = http.Post(**http_params)
p = printer.ConsolePrinter()
g = graph.Graph('test_post_graph', [v, post_data, h, p])
g.connect(p, h, 'message')
g.connect(h, v, 'url')
... | http_params = dict(url=url, mime_type='application/json', verify_ssl=False) |
Here is a snippet: <|code_start|> instance.input(dict(argument=[True, False, False]))
instance.set_output_label('any')
assert instance.output() == [False, True, True]
def test_and():
expected_reqs = ['function', 'argument']
instance = logics.And()
assert instance.requirements == expected_reqs
... | assert not instance.output() |
Predict the next line for this snippet: <|code_start|> instance.connect(root, leaf1, 'any1')
instance.connect(root, leaf2, 'any2')
result = instance.root_node
assert result == root
def test_remove_node():
root = Identity(name='root')
leaf1 = Identity(name='leaf1')
leaf2 = Identity(name='lea... | instance.remove_nodes([leaf1, leaf2]) |
Given snippet: <|code_start|>
def test_len():
root = Identity(name='root')
leaf1 = Identity(name='leaf1')
leaf2 = Identity(name='leaf2')
instance = graph.Graph('testgraph', [leaf1, leaf2, root])
assert len(instance) == 3
def test_has_isles():
root = Identity(name='root')
med1 = Identity(n... | for n in g.nodes: |
Predict the next line after this snippet: <|code_start|>
# Tests
def test_get_nodes():
n1 = Identity(name='testnode')
n2 = Identity(name='testnode')
instance = graph.Graph('testgraph', [n1, n2])
nodes = instance.nodes
assert len(nodes) == 2
assert n1 in nodes
assert n2 in nodes
def test_... | nodes = instance.nodes |
Here is a snippet: <|code_start|>
def test_reducer():
seq = [1, 2, 3, 4]
expected_result = -24
expected_reqs = ['reducing_function', 'sequence']
instance = fo.Reducer()
assert instance.requirements == expected_reqs
instance.input(dict(reducing_function=lambda x, y: -x*y, sequence=seq))
inst... | expected_reqs = ['sorting_function', 'sequence'] |
Using the snippet: <|code_start|>
def check_date(year, month, day):
assert len(year) == 4
assert len(month) == 2
m = int(month)
assert 1 <= m <= 12
assert len(day) == 2
d = int(day)
assert 1 <= d <= 31
def check_time(hours, minutes, seconds):
assert len(hours) == 2
hh = int(hours)... | ss = int(seconds) |
Predict the next line for this snippet: <|code_start|>
def sort_and_unique(input_file_path, output_file_path):
file_reader = files.TextFileReader(filepath=input_file_path,
encoding='UTF-8',
name="file_reader")
to_string_list = apply.... | g.connect(uniquer, to_string_list, 'argument') |
Given the code snippet: <|code_start|># Read from an input file a list of strings, remove duplicates, sort remaining
# items and then write them back to a different file
def sort_and_unique(input_file_path, output_file_path):
file_reader = files.TextFileReader(filepath=input_file_path,
... | encoding='UTF-8', |
Based on the snippet: <|code_start|># Read from an input file a list of strings, remove duplicates, sort remaining
# items and then write them back to a different file
def sort_and_unique(input_file_path, output_file_path):
file_reader = files.TextFileReader(filepath=input_file_path,
... | name="to_string_list") |
Based on the snippet: <|code_start|># Demo on how to stop a graph execution
def execution_stop(number):
def stop_here(value):
if value >= 0:
raise exceptions.StopGraphExecutionSignal('arg is positive')
raise exceptions.StopGraphExecutionSignal('arg is negative')
v = value.Value(... | g.connect(a, v, 'argument') |
Predict the next line for this snippet: <|code_start|># Demo on how to stop a graph execution
def execution_stop(number):
def stop_here(value):
if value >= 0:
raise exceptions.StopGraphExecutionSignal('arg is positive')
raise exceptions.StopGraphExecutionSignal('arg is negative')
... | g.connect(a, v, 'argument') |
Based on the snippet: <|code_start|>
def test_requirements():
expected = ['function', 'argument']
instance = apply.Apply()
<|code_end|>
, predict the immediate next line with the help of imports:
from robograph.datamodel.nodes.lib import apply
and context (classes, functions, sometimes code) from other files... | assert instance.requirements == expected |
Given the following code snippet before the placeholder: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply... | name="if") |
Using the snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lambda x: "hello" in x,
... | g.connect(p, s, 'message') |
Using the snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lambda x: "hello" in x,
... | name="if") |
Predict the next line after this snippet: <|code_start|># Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead
def replace_word(text):
t = value.Value(value=text, name="text")
s = branching.IfThenApply(condition=lamb... | function_false=lambda x: x.replace(" ", "_"), |
Based on the snippet: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
<|code_end|>
, predict the immediate next... | smtp_server_params['mime_type'] = 'text/html' |
Given the following code snippet before the placeholder: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
sm... | return g |
Predict the next line for this snippet: <|code_start|># Given an IP address, geolocate it and send the result over via e-mail
def email_geolocated_ip(recipients_list, smtp_server_params, ip_addr):
subject = value.Value(value='Test mail')
smtp_server_params['sender'] = 'test@test.com'
smtp_server_params[... | http_params = dict(url='https://api.ip2country.info/ip?'+ip_addr, |
Predict the next line for this snippet: <|code_start|>
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum value')
g.connect(b, m, 'product value')
g.connect(s, v, 'argument')
g.connect(m, v, 'argument')
return g
def logged_sum_and_product(... | return g |
Given the following code snippet before the placeholder: <|code_start|> m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
b = buffers.Buffer()
p = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum value')... | g.connect(s, v, 'argument') |
Here is a snippet: <|code_start|> v = value.Value(value=list_of_numbers)
s = apply.Apply(function=sum)
m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
b = buffers.Buffer()
p = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'mes... | g.connect(b, s, 'sum value') |
Using the snippet: <|code_start|> m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
b = buffers.Buffer()
p = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum value')
g.connect(b, m, 'product value')
... | g.connect(s, v, 'argument') |
Continue the code snippet: <|code_start|> v = value.Value(value=list_of_numbers)
s = apply.Apply(function=sum)
m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
b = buffers.Buffer()
p = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p,... | g.connect(b, s, 'sum value') |
Given the code snippet: <|code_start|>
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum value')
g.connect(b, m, 'product value')
g.connect(s, v, 'argument')
g.connect(m, v, 'argument')
return g
def logged_sum_and_product(list_of_numbers)... | return g |
Predict the next line after this snippet: <|code_start|># Given a list of numbers, calculate its sum and product and print it on screen
def sum_and_product(list_of_numbers):
v = value.Value(value=list_of_numbers)
s = apply.Apply(function=sum)
m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y,... | g.connect(s, v, 'argument') |
Next line prediction: <|code_start|> b = buffers.Buffer()
p = printer.ConsolePrinter()
g = graph.Graph('sum_and_product', [v, s, m, p, b])
g.connect(p, b, 'message')
g.connect(b, s, 'sum value')
g.connect(b, m, 'product value')
g.connect(s, v, 'argument')
g.connect(m, v, 'argument')
... | g.connect(m, v, 'argument') |
Continue the code snippet: <|code_start|># Given a list of numbers, calculate its sum and product and print it on screen
def sum_and_product(list_of_numbers):
v = value.Value(value=list_of_numbers)
s = apply.Apply(function=sum)
m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
b = bu... | g.connect(b, s, 'sum value') |
Predict the next line after this snippet: <|code_start|># Given a list of numbers, calculate its sum and product and print it on screen
def sum_and_product(list_of_numbers):
v = value.Value(value=list_of_numbers)
s = apply.Apply(function=sum)
m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y,... | g.connect(s, v, 'argument') |
Continue the code snippet: <|code_start|>
def test_sum():
seq = [1, -4, 7, 3]
instance = maths.Sum()
instance.input(dict(argument=seq))
instance.set_output_label('any')
assert 7 == instance.output()
def test_product():
seq = [1, -4, 7, 3]
instance = maths.Product(argument=seq)
instanc... | def test_sqrt(): |
Continue the code snippet: <|code_start|># Downloads an image from a remote HTTP server and saves it to a local file
def scraper_image(img_url, target_path):
url = value.Value(value=img_url)
client = http.Get(mime_type='image/png', )
writer = files.BinaryFileWriter(filepath=target_path)
g = graph.Gr... | g.connect(client, url, 'url') |
Given the following code snippet before the placeholder: <|code_start|># Downloads an image from a remote HTTP server and saves it to a local file
def scraper_image(img_url, target_path):
url = value.Value(value=img_url)
client = http.Get(mime_type='image/png', )
writer = files.BinaryFileWriter(filepath=... | g.connect(client, url, 'url') |
Given snippet: <|code_start|># Downloads an image from a remote HTTP server and saves it to a local file
def scraper_image(img_url, target_path):
url = value.Value(value=img_url)
client = http.Get(mime_type='image/png', )
writer = files.BinaryFileWriter(filepath=target_path)
g = graph.Graph('scrape_... | g.connect(client, url, 'url') |
Continue the code snippet: <|code_start|>
class PWETimeSeriesModule:
CONSTANT_STATE_KEYWORD = 'constant'
@staticmethod
def group_by_time(dfs, rels):
time_to_state_mapper = {}
temporal_rels = [rel for rel in rels
if ((META_DATA_TEMPORAL_DEC_KEYWORD in rel.meta_data... | if t not in time_to_state_mapper: |
Given the following code snippet before the placeholder: <|code_start|>
def parse_pwe_meta_data(asp_rules, silent=False, print_parse_tree=False):
if isinstance(asp_rules, str):
asp_rules = asp_rules.splitlines()
md_comments = preprocess(asp_rules)
md_comments = "\n".join(md_comments)
parsed_met... | return parse_pwe_meta_data(asp_rules, silent, print_parse_tree) |
Continue the code snippet: <|code_start|>
def get_colors_list(df, id):
idx = list(map(int, list(df[df.pw == id].x1)))
clrs = list(df[df.pw == id].x2)
ordered_clrs = [x for _, x in sorted(zip(idx, clrs))]
return ordered_clrs
def visualize(**kwargs):
kwargs = defaultdict(lambda: None, kwargs)
... | else: |
Continue the code snippet: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_t... | head, tail = row[edge_head_attr_name], row[edge_tail_attr_name] |
Predict the next line after this snippet: <|code_start|>
for i, row in rel_df.iterrows():
head, tail = row[edge_head_attr_name], row[edge_tail_attr_name]
curr_edge_style = {}
for prop_name, prop_type, prop_value in edge_styles:
if prop_type... | return G |
Here is a snippet: <|code_start|>def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_type == MET... | for prop_name, prop_type, prop_value in edge_styles: |
Given snippet: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_type == META... | rel_df = pw_rel_dfs[edge_rel_name] |
Next line prediction: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_type =... | head, tail = row[edge_head_attr_name], row[edge_tail_attr_name] |
Continue the code snippet: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_... | else: |
Using the snippet: <|code_start|> edge_head_attr_name = rel_df.columns[edge_rel_details[META_DATA_GRAPHVIZ_EDGE_HEAD_IDX_DEF_KEYWORD] + 1]
edge_tail_attr_name = rel_df.columns[edge_rel_details[META_DATA_GRAPHVIZ_EDGE_TAIL_IDX_DEF_KEYWORD] + 1]
edge_styles = edge_rel_details[META_DATA_... | curr_node_style[prop_name] = prop_value |
Based on the snippet: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
<|code_end|>
, predict the immediate next l... | G = nx.Graph() |
Continue the code snippet: <|code_start|>def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_typ... | for prop_name, prop_type, prop_value in edge_styles: |
Next line prediction: <|code_start|>
def build_nx_from_metadata(pw_rel_dfs: dict, graphviz_meta_data: dict):
graph_type = graphviz_meta_data[META_DATA_GRAPHVIZ_GRAPH_DEF_KEYWORD][META_DATA_GRAPHVIZ_GRAPH_TYPE]
if graph_type == META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD:
G = nx.Graph()
elif graph_type ... | else: |
Given snippet: <|code_start|>
for edge_rel_name, edge_rel_details in sorted(graphviz_meta_data[META_DATA_GRAPHVIZ_EDGE_DEF_KEYWORD].items(),
key=sort_by_ord_key):
if edge_rel_name in pw_rel_dfs:
rel_df = pw_rel_dfs[edge_rel_name]
edge... | for prop_name, prop_type, prop_value in node_styles: |
Given snippet: <|code_start|> G = nx.DiGraph()
else:
print("Unrecognized {} attribute. Choose one of ({})".
format(META_DATA_GRAPHVIZ_GRAPH_TYPE,
", ".join([META_DATA_GRAPHVIZ_UNDIRECTED_KEYWORD, META_DATA_GRAPHVIZ_DIRECTED_KEYWORD])))
return None
graph... | G.add_edge(head, tail, **curr_edge_style) |
Here is a snippet: <|code_start|>#!/usr/bin/env python3
class PWEExport:
@staticmethod
def get_sqlite_schema(dfs):
# this approach will take constant time since there is just one row in the exported database.
TEST_DB_LOCATION = os.path.abspath("test.db")
conn_t = sqlite3.connect(TES... | t.to_sql(str(rl_name), conn_t, if_exists='replace') |
Based on the snippet: <|code_start|>#!/usr/bin/env python3
class PWEExport:
@staticmethod
def get_sqlite_schema(dfs):
# this approach will take constant time since there is just one row in the exported database.
TEST_DB_LOCATION = os.path.abspath("test.db")
conn_t = sqlite3.connect(... | os.remove(TEST_DB_LOCATION) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
class PWEExport:
@staticmethod
def get_sqlite_schema(dfs):
# this approach will take constant time since there is just one row in the exported database.
TEST_DB_LOCATION = os.path.abspath("test.db")
conn_t = sqlite3.con... | schemas.append(row[4]) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
class PWEExport:
@staticmethod
def get_sqlite_schema(dfs):
# this approach will take constant time since there is just one row in the exported database.
TEST_DB_LOCATION = os.path.abspath("test.db")
conn_t = sqlite3.con... | for rl_name, df in dfs.items(): |
Using the snippet: <|code_start|>#!/usr/bin/env python3
# from sklearn.decomposition import PCA
class PWEVisualization:
@staticmethod
def dbscan_clustering(dist_matrix, save_to_file=None):
fig, ax = plt.subplots()
db = DBSCAN(metric='precomputed', eps=0.5, min_samples=1)
labels = ... | labels = db.labels_ |
Next line prediction: <|code_start|>
def get_telingo_output(telingo_in_fnames: list, num_solutions: int=0):
t = ['telingo', '-n {}'.format(num_solutions), '-Wnone']
t.extend(telingo_in_fnames)
process_ = subprocess.Popen(t, stdout=subprocess.PIPE)
telingo_output = process_.communicate()[0]
# clingo... | meta_data = {} |
Using the snippet: <|code_start|>
def get_telingo_output(telingo_in_fnames: list, num_solutions: int=0):
t = ['telingo', '-n {}'.format(num_solutions), '-Wnone']
t.extend(telingo_in_fnames)
process_ = subprocess.Popen(t, stdout=subprocess.PIPE)
telingo_output = process_.communicate()[0]
# clingo_ou... | teling_out_lines = telingo_output.splitlines() |
Given snippet: <|code_start|>
def get_clingo_output(clingo_in_fnames: list, num_solutions: int=0, show_warnings=False, other_args: list=None):
t = ['clingo', '-n {}'.format(num_solutions)]
# TODO The thing below won't do much if warnings are sent to stderr which I suspect they are.
# TODO Also need to shif... | meta_data[md_type].update(md) |
Predict the next line after this snippet: <|code_start|>
def get_clingo_output(clingo_in_fnames: list, num_solutions: int=0, show_warnings=False, other_args: list=None):
t = ['clingo', '-n {}'.format(num_solutions)]
# TODO The thing below won't do much if warnings are sent to stderr which I suspect they are.
... | for md_type, md in f_meta_data.items(): |
Based on the snippet: <|code_start|> self.handlers[path] = handler
def url(self, path):
"""
Get the full URL for a specific path.
:param path: Path to be accessed.
:return: A full URL, including the port number.
"""
path = ensure_slash(path)
return 'h... | (defun fixed-handler (body) |
Given the following code snippet before the placeholder: <|code_start|> self.key = uuid.uuid4()
self.port = 0 # Will be set later
def send_request(self, path, body=None, params=None):
"""
Execute a HTTP request *from the AG server*.
This will be a GET request, unless the `b... | :content {body})) |
Predict the next line for this snippet: <|code_start|># Lisp code used to run an HTTP server.
# Note that it is a .format() string and expects a security key
# to be passed in the {key} keyword argument.
server_code = """
(use-package :net.aserve)
(defun fixed-handler (body)
(lambda (req ent)
(with-http-response... | (let ((server (start :port 0 :host "127.0.0.1" :server :new))) |
Next line prediction: <|code_start|>
@pytest.fixture
def http_server():
"""
A fixture wrapping the HTTP server, takes care of starting and stopping it.
:return:
"""
with contextlib.closing(HTTPServer()) as server:
server.start()
yield server
# Lisp code used to run an HTTP server.
... | (type (or (request-query-value "type" req) "text/plain"))) |
Given snippet: <|code_start|> """
with contextlib.closing(HTTPServer()) as server:
server.start()
yield server
# Lisp code used to run an HTTP server.
# Note that it is a .format() string and expects a security key
# to be passed in the {key} keyword argument.
server_code = """
(use-package :ne... | (defun stop (req ent) |
Given the code snippet: <|code_start|> A fixture wrapping the HTTP server, takes care of starting and stopping it.
:return:
"""
with contextlib.closing(HTTPServer()) as server:
server.start()
yield server
# Lisp code used to run an HTTP server.
# Note that it is a .format() string and e... | :server (request-wserver req))))))) |
Predict the next line after this snippet: <|code_start|> :param path: Path to be accessed.
:return: A full URL, including the port number.
"""
path = ensure_slash(path)
return 'http://127.0.0.1:%d%s' % (self.server.server_port, path)
@pytest.fixture
def http_server():
"""
... | (defun pub (req ent) |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
################################################################################
# Copyright (c) 2006-2017 Franz Inc.
# All rights reserved. This program and the accompanying materials are
# made available u... | def __init__(self, rdfFormat, filePath=None): |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
################################################################################
# Copyright (c) 2006-2017 Franz Inc.
# All rights reserved. This program and the accompanying materials are
# made available under th... | class OWL(object): |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
################################################################################
# Copyright (c) 2006-2017 Franz Inc.
# All rights reserved. This program and the accompanying materials are
# made availa... | class XMLSchema(object): |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
################################################################################
# Copyright (c) 2006-2017 Franz Inc.
# All rights reserved. This program and the accompanying materials are
# made available und... | @python_2_unicode_compatible |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103
################################################################################
# Copyright (c) 2006-2017 Franz Inc.
# All rights reserved. This program and the accompanying materials are
# made available u... | SPARQL = None |
Predict the next line after this snippet: <|code_start|>## <li>If this fails, find the <em>last</em> occurrence of the ':'
## character.
## <li>Add <tt>1<tt> to the found index and return this value.
## </ul>
## Note that the third step should never fail as every legal (non-relative)
## URI contains at least one ':' ch... | value = unicode(value) |
Based on the snippet: <|code_start|>
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
def __repr__(self):
return '<%s>' % self.__class__.__name__
def validate(self):
pass
def save(self, validate=True):
try:
adapter.add(self)
... | if commit: |
Given the following code snippet before the placeholder: <|code_start|> return '<%s>' % self.__class__.__name__
def validate(self):
pass
def save(self, validate=True):
try:
adapter.add(self)
adapter.commit()
except:
adapter.rollback()
... | res = adapter.session.query(cls).filter(cls.id == id).first() |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding:utf-8 -*-
class KMUserAdmin:
@classmethod
def save_user(cls, data):
id = data.get_request_parameter("id")
delete = data.get_request_parameter("delete", default=None)
if delete is None:
user = KMUser.get(id)... | delete = data.get_request_parameter("delete", default=None) |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding:utf-8 -*-
class KMUserAdmin:
@classmethod
def save_user(cls, data):
id = data.get_request_parameter("id")
delete = data.get_request_parameter("delete", default=None)
if delete is None:
user = KMUser.get(id)... | def save_group(cls, data): |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding:utf-8 -*-
class KMUserAdmin:
@classmethod
def save_user(cls, data):
id = data.get_request_parameter("id")
delete = data.get_request_parameter("delete", default=None)
if delete is None:
... | group.save() |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'hiroki'
class KMEngine(KMBaseController):
def get_name(self):
return 'engine'
def get_route_list(self):
list = (
{'rule': '/engine-js/<filename>', 'method': 'GET',... | {'rule': '/error', 'method': 'GET', 'target': self.engine_error}, |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'hiroki'
class KMEngine(KMBaseController):
def get_name(self):
return 'engine'
def get_route_list(self):
list = (
{'rule': '/engine-js/<filename>', 'method': 'GET', 'target': self.engine_js... | {'rule': '/error', 'method': 'GET', 'target': self.engine_error}, |
Given the code snippet: <|code_start|>
class Roles(Base):
endpoint = "/roles"
def get_role_by_id(self, role_id):
return self.client.get(self.endpoint + "/" + role_id)
def get_role_by_name(self, role_name):
return self.client.get(self.endpoint + "/name/" + role_name)
<|code_end|>
, genera... | def patch_role(self, role_id, options=None): |
Based on the snippet: <|code_start|>
class LDAP(Base):
endpoint = "/ldap"
def sync_ldap(self):
return self.client.post(self.endpoint + "/sync")
<|code_end|>
, predict the immediate next line with the help of imports:
from .base import Base
and context (classes, functions, sometimes code) from other... | def test_ldap_config(self): |
Predict the next line for this snippet: <|code_start|>
class Webhooks(Base):
endpoint = "/hooks"
def create_incoming_hook(self, options):
return self.client.post(self.endpoint + "/incoming", options=options)
def list_incoming_hooks(self, params):
return self.client.get(self.endpoint + "/i... | return self.client.get(self.endpoint + "/incoming/" + hook_id) |
Using the snippet: <|code_start|>
def update_user_mfa(self, user_id, options=None):
return self.client.put(self.endpoint + "/" + user_id + "/mfa", options)
def generate_mfa(self, user_id):
return self.client.post(self.endpoint + "/" + user_id + "/mfa/generate")
def check_mfa(self, options=... | def attach_mobile_device(self, options=None): |
Based on the snippet: <|code_start|>
class Bots(Base):
endpoint = "/bots"
def create_bot(self, options):
return self.client.post(self.endpoint, options=options)
def get_bots(self, params=None):
return self.client.get(self.endpoint, params=params)
def patch_bot(self, bot_id, options):... | return self.client.post(self.endpoint + "/" + bot_id + "/icon", files=files) |
Given snippet: <|code_start|>
class Scheme(Base):
endpoint = "/schemes"
def get_schemes(self, params=None):
return self.client.get(self.endpoint, params=params)
def create_scheme(self, options=None):
return self.client.post(self.endpoint, options=options)
def get_scheme(self, scheme_... | def get_page_of_channels_using_scheme(self, scheme_id, params=None): |
Given snippet: <|code_start|>
class Compliance(Base):
endpoint = "/compliance"
def create_report(self, params):
return self.client.post(self.endpoint + "/reports", params=params)
def get_reports(self, params=None):
<|code_end|>
, continue by predicting the next line. Consider current file imports... | return self.client.get(self.endpoint + "/reports", params=params) |
Predict the next line for this snippet: <|code_start|>
class DataRetention(Base):
endpoint = "/data_retention"
def get_data_retention_policy(self):
<|code_end|>
with the help of current file imports:
from .base import Base
and context from other files:
# Path: src/mattermostdriver/endpoints/base.py
# clas... | return self.client.get(self.endpoint + "/policy") |
Continue the code snippet: <|code_start|>
class IntegrationActions(Base):
endpoint = "/actions"
def open_dialog(self, options):
return self.client.post(self.endpoint + "/dialogs/open", options=options)
def submit_dialog(self, options):
<|code_end|>
. Use current file imports:
from .base import B... | return self.client.post(self.endpoint + "/dialogs/submit", options=options) |
Predict the next line for this snippet: <|code_start|>
class Files(Base):
endpoint = "/files"
def upload_file(self, channel_id, files):
return self.client.post(self.endpoint, data={"channel_id": channel_id}, files=files)
def get_file(self, file_id):
return self.client.get(
sel... | def get_file_thumbnail(self, file_id): |
Given the code snippet: <|code_start|>
class Emoji(Base):
endpoint = "/emoji"
def create_custom_emoji(self, emoji_name, files):
emoji = {"name": emoji_name, "creator_id": self.client.userid}
return self.client.post(self.endpoint, data={"emoji": json.dumps(emoji)}, files=files)
def get_em... | return self.client.get(self.endpoint + "/autocomplete", params=params) |
Using the snippet: <|code_start|>
class Status(Base):
def get_user_status(self, user_id):
return self.client.get("/users/" + user_id + "/status")
def update_user_status(self, user_id, options=None):
return self.client.put("/users/" + user_id + "/status", options=options)
<|code_end|>
, determ... | def get_user_statuses_by_id(self, options=None): |
Based on the snippet: <|code_start|>
class DriftDetectOptions(namedtuple('DriftDetectOptions',
['no_wait', ])):
pass
waiter_model = botocore.waiter.WaiterModel({
"version": 2,
"waiters": {
"DriftDetectionComplete": {
"delay": 15,
"opera... | "acceptors": [ |
Using the snippet: <|code_start|>
def package_template(ppt, session, template_path, bucket_region,
bucket_name=None, prefix=None, kms_key_id=None):
# validate template path
if not os.path.isfile(template_path):
raise ConfigError('Invalid Template Path "%s"' % template_path)
# i... | ) |
Given the following code snippet before the placeholder: <|code_start|># -*- encoding: utf-8 -*-
@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,... | help='Don\'t exit with error if the stack is missing.') |
Given snippet: <|code_start|># -*- encoding: utf-8 -*-
@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,
help='Exit immediately afte... | 'Be more specific using --stack option.', abort=True) |
Predict the next line after this snippet: <|code_start|>
@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,
help='Exit immediately after d... | options=options |
Given the following code snippet before the placeholder: <|code_start|># -*- encoding: utf-8 -*-
@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,... | def delete(ctx, quiet, no_wait, ignore_missing): |
Given the code snippet: <|code_start|> for k, v in
six.iteritems(OrderedDict(
sorted(six.iteritems(Parameters)))
)
)
# Normalize tag config
Tags = parameters['Tags']
normalized_tags = None
if Tags and isinstance(Tags, dict):
normalized_... | StackPolicyBody=StackPolicyBody, |
Continue the code snippet: <|code_start|>
def normalize_value(v):
if isinstance(v, bool):
return 'true' if v else 'false'
elif isinstance(v, int):
return str(v)
else:
return v
def make_boto3_parameters(parameters, is_packaging):
# inject parameters
<|code_end|>
. Use current... | StackName = parameters['StackName'] |
Here is a snippet: <|code_start|>
class StackStatusOptions(namedtuple('StackStatusOptions',
['dry_run', 'stack_resources',
'stack_exports'])):
pass
dummy_stack = namedtuple('dummy_stack', ['stack_name', 'stack_status'])
class StackStatus... | return |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.