prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_text
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_bytes
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_string
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_dict
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_dict_None
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_list
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_list_None
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_set
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_set_None
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_tuple
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_tuple_None
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_None
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_unsafe_text
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_unsafe_bytes
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_wrap_var_no_ref
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_AnsibleUnsafeText
<|file_name|>test_unsafe_proxy.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # (c) 2018 Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible....
test_AnsibleUnsafeBytes
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
context.execute_steps(u''' given I open History dialog ''') history = context.browser.find_element_by_id("HistoryPopup") entries = history.find_elements_by_xpath('.//li[not(@data-clone-template)]') assert len(entries) > 0, "There are no entries in the history" item = entries[0] item....
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
WebDriverWait(context.browser, 10).until( expected_conditions.visibility_of_element_located( (By.ID, 'ShareRequestForm'))) output = context.browser.execute_script("return restman.ui.editors.get('#ShareRequestEditor').getValue();") snippet = json.loads(output) assert url == snippet[...
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
context.execute_steps(u''' given I open History dialog ''') # Click on import context.browser.find_element_by_id('ImportHistory').click() WebDriverWait(context.browser, 10).until( expected_conditions.visibility_of_element_located( (By.ID, 'ImportRequestForm')))
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
req = json.dumps({ "method": "POST", "url": url, "headers": { "Content-Type": "application/json", "X-Test-Header": "shared_request" }, "body": { "type": "form", "content": { "SomeKey": "SomeValue11233", ...
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
context.browser.find_element_by_xpath("//*[@id='ImportRequestForm']//input[@value='Import']").click()
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
step_impl
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
step_impl
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
step_impl
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
step_impl
<|file_name|>share.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # -*- coding: utf-8 -*- import base64 import json from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from behave import * @step('I share...
step_impl
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'''Folder containing publ...
grok.context(IPublicationFolder)
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'<|fim_middle|> class Pu...
''Folder containing publications.'''
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'''Folder containing publ...
''RDF ingestor for publication.''' grok.context(IPublicationFolder) def getContainedObjectInterface(self): return IPublication
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'''Folder containing publ...
turn IPublication
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'''Folder containing publ...
''View for an publication folder''' grok.context(IPublicationFolder)
<|file_name|>publicationfolder.py<|end_file_name|><|fim▁begin|># encoding: utf-8 u'''MCL — Publication Folder''' from ._base import IIngestableFolder, Ingestor, IngestableFolderView from .interfaces import IPublication from five import grok class IPublicationFolder(IIngestableFolder): u'''Folder containing publ...
tContainedObjectInterface(s
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
@ndb.transactional def increase_shards(name, num_shards):
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): <|fim_middle|> class GeneralCounterShard(ndb.Model): count = ndb.Integ...
num_shards = ndb.IntegerProperty(default=20) @classmethod def all_keys(cls, name): config = cls.get_or_insert(name) shard_key_strings = [SHARD_KEY_TEMPLATE.format(name, index) for index in range(config.num_shards)] return [ndb.Key(GeneralCounterShard, shard_key_string) for shard_key...
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
config = cls.get_or_insert(name) shard_key_strings = [SHARD_KEY_TEMPLATE.format(name, index) for index in range(config.num_shards)] return [ndb.Key(GeneralCounterShard, shard_key_string) for shard_key_string in shard_key_strings]
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
count = ndb.IntegerProperty(default=0)
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
total = memcache.get(name) if total is None: total = 0 parent_key = ndb.Key('ShardCounterParent', name) shard_query = GeneralCounterShard.query(ancestor=parent_key) shard_counters = shard_query.fetch(limit=None) for counter in shard_counters: if counter is...
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
config = GeneralCounterShardConfig.get_or_insert(name) return _increment(name, config.num_shards)
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
index = random.randint(0, num_shards - 1) shard_key_string = SHARD_KEY_TEMPLATE.format(name, index) parent_key = ndb.Key('ShardCounterParent', name) counter = GeneralCounterShard.get_by_id(shard_key_string, parent = parent_key) if counter is None: counter = GeneralCounterShard(parent = pa...
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
config = GeneralCounterShardConfig.get_or_insert(name) if config.num_shards < num_shards: config.num_shards = num_shards config.put()
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
total = 0 parent_key = ndb.Key('ShardCounterParent', name) shard_query = GeneralCounterShard.query(ancestor=parent_key) shard_counters = shard_query.fetch(limit=None) for counter in shard_counters: if counter is not None: total += counter.count ...
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
total += counter.count memcache.add(name, total, 7200) # 2 hours to expire
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
counter = GeneralCounterShard(parent = parent_key, id=shard_key_string)
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
return get_count(name)
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
config.num_shards = num_shards config.put()
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def <|fim...
all_keys
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
get_count
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
increment
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
_increment
<|file_name|>shardcounter_sync.py<|end_file_name|><|fim▁begin|>import random from google.appengine.api import memcache from google.appengine.ext import ndb SHARD_KEY_TEMPLATE = 'shard-{}-{:d}' class GeneralCounterShardConfig(ndb.Model): num_shards = ndb.IntegerProperty(default=20) @classmethod def all_k...
increase_shards
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): <|fim_middle|> def totient(n, prime_decs): if n not in prime_decs: return n - 1 res = n for prime in prime_decs[n]: ...
d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[j].add(i) j += i return d
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
if n not in prime_decs: return n - 1 res = n for prime in prime_decs[n]: res *= 1 - Fraction(1, prime) return int(res)
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
c = 1 prime_decs = reverse_erathos(n) res = [] for i in range(2, n + 1): if c % 50000 == 0: print(c) tot = totient(i, prime_decs) if Counter(str(i)) == Counter(str(tot)): res.append((i, tot, Fraction(i, tot))) c += 1 return min(res, key = lambd...
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: <|fim_middle|> return d def totient(...
j = 2 * i while j <= n: d[j].add(i) j += i
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
return n - 1
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
print(c)
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
res.append((i, tot, Fraction(i, tot)))
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def <|fim_middle|>(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[j...
reverse_erathos
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
totient
<|file_name|>problem.py<|end_file_name|><|fim▁begin|>from math import sqrt from collections import defaultdict, Counter from fractions import Fraction def reverse_erathos(n): d = defaultdict(set) for i in range(2, n + 1): if i not in d: j = 2 * i while j <= n: d[...
compute_solution
<|file_name|>__main__.py<|end_file_name|><|fim▁begin|># coding=utf-8<|fim▁hole|> tp.Main().parse_and_run()<|fim▁end|>
''' tagsPlorer package entry point (C) 2021-2021 Arne Bachmann https://github.com/ArneBachmann/tagsplorer ''' from tagsplorer import tp
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
asid = tokens[0].split("_")[0]
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): <|fim_middle|> def get_sable_scores(map_file, f_sable_db_location, uniprot_core_output_location): ...
uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: # PARSING ID prot = tokens[0] index = int(tokens[1]) core = tokens[2] # PARSING ID if uniprot_to_index_to_core.has_key(prot): ...
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
map_file_obj = open(map_file, 'r') sable_db_obj = open(f_sable_db_location, 'r') write_to = open(uniprot_core_output_location, 'w') uniprot_to_index_to_core = build_uniprot_to_index_to_core(sable_db_obj) for line in map_file_obj: tokens = line.split() asid = tokens[0].split("_")[0...
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
uniprot_to_index_to_core[prot][index] = core
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
uniprot_to_index_to_core[prot] = {index: core}
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
rough_a_length = 0
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
c1_count = score_differences(uniprot_to_index_to_core, prot, sstart, start) a_count = score_differences(uniprot_to_index_to_core, prot, start, end) c2_count = score_differences(uniprot_to_index_to_core, prot, end, eend) prot_len = int(line.split("\t")[7].strip()) ...
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def <|fim_middle|>(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: # PARS...
build_uniprot_to_index_to_core
<|file_name|>uniprot_core.py<|end_file_name|><|fim▁begin|># reads uniprot core file and generates core features from features_helpers import score_differences def build_uniprot_to_index_to_core(sable_db_obj): uniprot_to_index_to_core = {} for line in sable_db_obj: tokens = line.split() try: ...
get_sable_scores
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3<|fim▁hole|>from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env.bodies.append( ...
from pyamf import remoting
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): <|fim_middle|> def get_clip_info(const, play...
env = remoting.Envelope(amfVersion=3) env.bodies.append( ( "/1", remoting.Request( target="com.brightcove.player.runtime.PlayerMediaFacade.findMediaById", body=[const, playerID, videoPlayer, publisherID], envelope=env ) ...
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env....
conn = httplib.HTTPConnection("c.brightcove.com") envelope = build_amf_request(const, playerID, videoPlayer, publisherID) conn.request("POST", "/services/messagebroker/amf?playerKey=" + playerKey, str(remoting.encode(envelope).read()), {'content-type': 'application/x-amf'}) response = conn.getresponse()...
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env....
rtmpdata = get_clip_info(const, playerID, videoPlayer, publisherID, playerKey) streamName = "" streamUrl = rtmpdata['FLVFullLengthURL']; for item in sorted(rtmpdata['renditions'], key=lambda item:item['frameHeight'], reverse=False): streamHeight = item['frameHeight'] if str...
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env....
streamUrl = item['defaultURL']
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def <|fim_middle|>(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env.bod...
build_amf_request
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env....
get_clip_info
<|file_name|>brightcovePlayer.py<|end_file_name|><|fim▁begin|>import httplib from pyamf import AMF0, AMF3 from pyamf import remoting from pyamf.remoting.client import RemotingService height = 1080 def build_amf_request(const, playerID, videoPlayer, publisherID): env = remoting.Envelope(amfVersion=3) env....
play
<|file_name|>action_registry_test.py<|end_file_name|><|fim▁begin|># coding: utf-8 # # Copyright 2018 The Oppia Authors. All Rights Reserved. #<|fim▁hole|># you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
# Licensed under the Apache License, Version 2.0 (the "License");
<|file_name|>action_registry_test.py<|end_file_name|><|fim▁begin|># coding: utf-8 # # Copyright 2018 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # ...
"""Test for the action registry.""" def test_action_registry(self): """Do some sanity checks on the action registry.""" self.assertEqual( len(action_registry.Registry.get_all_actions()), 3)
<|file_name|>action_registry_test.py<|end_file_name|><|fim▁begin|># coding: utf-8 # # Copyright 2018 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # ...
"""Do some sanity checks on the action registry.""" self.assertEqual( len(action_registry.Registry.get_all_actions()), 3)
<|file_name|>action_registry_test.py<|end_file_name|><|fim▁begin|># coding: utf-8 # # Copyright 2018 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # ...
test_action_registry
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): def __init__(self, api_job): super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVolumeOpt...
def start(self): attributes = json.loads(self.api_job['attributes'].decode('utf-8')) vol_name = attributes['volname'] option = attributes['option_name']
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): <|fim_middle|> <|fim▁end|>
def __init__(self, api_job): super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVolumeOption def start(self): attributes = json.loads(self.api_job['attributes'].decode('utf-8')) vol_name = attributes['volname'] option = attributes['opti...
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): def __init__(self, api_job): <|fim_middle|> def start(self): attributes = json.loads(self.api_job['attributes'].decode...
super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVolumeOption
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): def __init__(self, api_job): super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVolumeOpt...
attributes = json.loads(self.api_job['attributes'].decode('utf-8')) vol_name = attributes['volname'] option = attributes['option_name'] option_value = attributes['option_value'] self.atom().start(vol_name, option, option_value) self.api_job['status'] = "finished" ...
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): def <|fim_middle|>(self, api_job): super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVol...
__init__
<|file_name|>set_volume_option.py<|end_file_name|><|fim▁begin|>import json import etcd from tendrl.gluster_bridge.atoms.volume.set import Set class SetVolumeOption(object): def __init__(self, api_job): super(SetVolumeOption, self).__init__() self.api_job = api_job self.atom = SetVolumeOpt...
start
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
parser.add_argument('stock_prices', action='store', nargs='+', help='prices of a given stock') return parser.parse_args()
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
parser = argparse.ArgumentParser(description='easy 249') parser.add_argument('stock_prices', action='store', nargs='+', help='prices of a given stock') return parser.parse_args()
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
buy_day = 0 max_profit = 0 max_buy = 0 max_sell = 0 for buy_day in range(len(stock_prices) - 2): # maybe do a max(here) for sell_day in range(buy_day + 2, len(stock_prices)): profit = stock_prices[sell_day] - stock_prices[buy_day] if profit > max_profit: ...
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
max_profit = profit max_buy = buy_day max_sell = sell_day
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
args = parse_args() stock([float(price) for price in args.stock_prices])
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
parse_args
<|file_name|>easy-249.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python3 ''' given a list of stock price ticks for the day, can you tell me what trades I should make to maximize my gain within the constraints of the market? Remember - buy low, sell high, and you can't sell before you buy. Sample Input 19.35 19.3...
stock
<|file_name|>discount.py<|end_file_name|><|fim▁begin|># Possible discounts: # - Node (administer inline with nodes) # - Bulk amounts on nodes # - User # - Group of users # - Order (this is more-or-less a voucher) # - Shipping costs # Possible amounts: # - Percentage # - Fixed amount<|fim▁hole|># Flag indicating if a di...
<|file_name|>sdb_dump_patch.py<|end_file_name|><|fim▁begin|>import sys import logging import hexdump import vstruct import vivisect import envi import envi.archs.i386 as x86 import envi.archs.amd64 as x64 import sdb from sdb import SDB_TAGS from sdb_dump_common import SdbIndex from sdb_dump_common import item_get_chi...