function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_invalid_type(self):
pl = [ object() ]
for fmt in ALL_FORMATS:
with self.subTest(fmt=fmt):
self.assertRaises(TypeError, plistlib.dumps, pl, fmt=fmt) | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_bytes(self):
pl = self._create()
data = plistlib.dumps(pl)
pl2 = plistlib.loads(data)
self.assertNotIsInstance(pl, plistlib._InternalDict)
self.assertEqual(dict(pl), dict(pl2))
data2 = plistlib.dumps(pl2)
self.assertEqual(data, data2) | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_indentation_dict(self):
data = {'1': {'2': {'3': {'4': {'5': {'6': {'7': {'8': {'9': b'aaaaaa'}}}}}}}}}
self.assertEqual(plistlib.loads(plistlib.dumps(data)), data) | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_appleformatting(self):
for use_builtin_types in (True, False):
for fmt in ALL_FORMATS:
with self.subTest(fmt=fmt, use_builtin_types=use_builtin_types):
pl = plistlib.loads(TESTDATA[fmt],
use_builtin_types=use_builtin_types)
... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_bytesio(self):
for fmt in ALL_FORMATS:
with self.subTest(fmt=fmt):
b = BytesIO()
pl = self._create(fmt=fmt)
plistlib.dump(pl, b, fmt=fmt)
pl2 = plistlib.load(BytesIO(b.getvalue()), fmt=fmt)
self.assertEqual(dict... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_keysort(self):
pl = collections.OrderedDict()
pl['b'] = 1
pl['a'] = 2
pl['c'] = 3
for fmt in ALL_FORMATS:
for sort_keys in (False, True):
with self.subTest(fmt=fmt, sort_keys=sort_keys):
data = plistlib.dumps(pl, fmt=fmt, ... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_skipkeys(self):
pl = {
42: 'aNumber',
'snake': 'aWord',
}
for fmt in ALL_FORMATS:
with self.subTest(fmt=fmt):
data = plistlib.dumps(
pl, fmt=fmt, skipkeys=True, sort_keys=False)
pl2 = plistlib.load... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_list_members(self):
pl = {
'first': [1, 2],
'second': [1, 2],
'third': [3, 4],
}
for fmt in ALL_FORMATS:
with self.subTest(fmt=fmt):
data = plistlib.dumps(pl, fmt=fmt)
pl2 = plistlib.loads(data)
... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_controlcharacters(self):
for i in range(128):
c = chr(i)
testString = "string containing %s" % c
if i >= 32 or c in "\r\n\t":
# \r, \n and \t are the only legal control chars in XML
plistlib.dumps(testString, fmt=plistlib.FMT_XML)
... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_invalidarray(self):
for i in ["<key>key inside an array</key>",
"<key>key inside an array2</key><real>3</real>",
"<true/><key>key inside an array3</key>"]:
self.assertRaises(ValueError, plistlib.loads,
("<plist><array>%s</arr... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_invalidinteger(self):
self.assertRaises(ValueError, plistlib.loads,
b"<plist><integer>not integer</integer></plist>") | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_xml_encodings(self):
base = TESTDATA[plistlib.FMT_XML]
for xml_encoding, encoding, bom in [
(b'utf-8', 'utf-8', codecs.BOM_UTF8),
(b'utf-16', 'utf-16-le', codecs.BOM_UTF16_LE),
(b'utf-16', 'utf-16-be', codecs.BOM_UTF16_BE),
... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_io_deprecated(self):
pl_in = {
'key': 42,
'sub': {
'key': 9,
'alt': 'value',
'data': b'buffer',
}
}
pl_out = plistlib._InternalDict({
'key': 42,
'sub': plistlib._InternalDict({
... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def test_dataobject_deprecated(self):
in_data = { 'key': plistlib.Data(b'hello') }
out_data = { 'key': b'hello' }
buf = plistlib.dumps(in_data)
cur = plistlib.loads(buf)
self.assertEqual(cur, out_data)
self.assertNotEqual(cur, in_data)
cur = plistlib.loads(buf,... | ArcherSys/ArcherSys | [
3,
2,
3,
16,
1412356452
] |
def take_snapshot(options):
esm = ElasticsearchSnapshotManager(options)
sh = esm.sh
snapshot = options.snapshot and options.snapshot or 'all_' + time.strftime('%Y%m%d%H')
snapdef = {
"include_global_state": True
}
if options.indices:
snapdef['indices'] = ','.join(options.indic... | DomainGroupOSS/elasticsearch-snapshots | [
23,
13,
23,
1,
1442386334
] |
def sslproxy_mock(url, request):
return """<table class="table table-striped table-bordered" cellspacing="0" width="100%" id="proxylisttable">
<thead>
<tr>
<th>IP Address</th>
<th>Port</th>
<th>Code</th>
<th class='hm'>Country</th>
<th>Anonymity</th>
<th class... | pgaref/HTTP_Request_Randomizer | [
140,
53,
140,
23,
1446231372
] |
def free_proxy_mock(url, request):
return """<table border="0" cellpadding="0" cellspacing="0" id="proxylisttable" | pgaref/HTTP_Request_Randomizer | [
140,
53,
140,
23,
1446231372
] |
def proxy_for_eu_mock(url, request):
return """<table class="proxy_list">
<tr>
<th>IP</th>
<th>Port</th>
<th>Country</th>
<th>Anon</th>
<th>Speed</th>
<th> Check</th>
<th>Cookie/POST</th>
</tr>
<tr>
<td>107.151.136.222</td>
<td>80</... | pgaref/HTTP_Request_Randomizer | [
140,
53,
140,
23,
1446231372
] |
def rebro_weebly_mock(url, request):
return """<div class="paragraph" style="text-align:left;"><strong><font color="#3ab890" size="3"><font
color="#d5d5d5">IP:Port</font></font></strong><br/><font
size="2"><strong><font color="#33a27f">213.149.105.12:8080<br/>119.188.46.42:8080</font></strong></font... | pgaref/HTTP_Request_Randomizer | [
140,
53,
140,
23,
1446231372
] |
def prem_mock(url, request):
return """
<head>
<script src="/js/test.js"></script>
</head>
<div id="proxylist">\n
<tr class="anon">\n
<th><a href="/list/ip-address-01.htm" title="Proxy List sorted by ip address">IP address</a></th>
\n
<th><a href="/list/" title="Proxy... | pgaref/HTTP_Request_Randomizer | [
140,
53,
140,
23,
1446231372
] |
def __init__(self, x: int, y: int):
self.x = x
self.y = y | sqlalchemy/sqlalchemy | [
6899,
1088,
6899,
170,
1543289703
] |
def __repr__(self) -> str:
return "Point(x=%r, y=%r)" % (self.x, self.y) | sqlalchemy/sqlalchemy | [
6899,
1088,
6899,
170,
1543289703
] |
def __ne__(self, other: Any) -> bool:
return not self.__eq__(other) | sqlalchemy/sqlalchemy | [
6899,
1088,
6899,
170,
1543289703
] |
def main():
if DEBUG:
test()
n = int(input())
paths = cycles(n)
print(len(paths))
for p in paths:
print('%d %s' % (len(p), ' '.join([str(v) for v in p]))) | andreimaximov/algorithms | [
100,
43,
100,
5,
1435729230
] |
def even(n):
"""Builds a set of cycles that a graph with even vertices."""
assert n % 2 == 0
# Base case for complete graph such that V = {1, 2, 3, 4}.
cycles = [[1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2]]
for i in range(6, n + 1, 2):
a, b = i, i - 1
# Use edges (a, 1), (a, 0), (b... | andreimaximov/algorithms | [
100,
43,
100,
5,
1435729230
] |
def test():
"""Checks the cycles(...) solver for a bunch of inputs."""
print('Testing...')
for n in range(3, 300, 21):
check(n, cycles(n))
print('Tests pass!') | andreimaximov/algorithms | [
100,
43,
100,
5,
1435729230
] |
def parent(self):
if self._values['parent'] is None:
return None
result = fq_name(self.partition, self._values['parent'])
return result | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def streams(self):
streams = self._values['streams']
if streams is None:
return None
if streams < 1 or streams > 256:
raise F5ModuleError(
"Streams value must be between 1 and 256"
)
return self._values['streams'] | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def receive_window(self):
window = self._values['receive_window']
if window is None:
return None
if window < 16 or window > 128:
raise F5ModuleError(
"Receive Window value must be between 16 and 128"
)
return self._values['receive_windo... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def header_table_size(self):
header = self._values['header_table_size']
if header is None:
return None
if header < 0 or header > 65535:
raise F5ModuleError(
"Header Table Size value must be between 0 and 65535"
)
return self._values['he... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def write_size(self):
write = self._values['write_size']
if write is None:
return None
if write < 2048 or write > 32768:
raise F5ModuleError(
"Write Size value must be between 2048 and 32768"
)
return self._values['write_size'] | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def frame_size(self):
frame = self._values['frame_size']
if frame is None:
return None
if frame < 1024 or frame > 16384:
raise F5ModuleError(
"Write Size value must be between 1024 and 16384"
)
return self._values['frame_size'] | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def enforce_tls_requirements(self):
result = flatten_boolean(self._values['enforce_tls_requirements'])
if result is None:
return None
if result == 'yes':
return 'enabled'
return 'disabled' | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def insert_header(self):
result = flatten_boolean(self._values['insert_header'])
if result is None:
return None
if result == 'yes':
return 'enabled'
return 'disabled' | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def activation_modes(self):
value = self._values['activation_modes']
if value is None:
return None
if is_empty_list(value):
raise F5ModuleError(
"Activation Modes cannot be empty, please provide a value"
)
return value | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def to_return(self):
result = {}
try:
for returnable in self.returnables:
result[returnable] = getattr(self, returnable)
result = self._filter_params(result)
except Exception:
pass
return result | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def insert_header(self):
if self._values['insert_header'] is None:
return None
elif self._values['insert_header'] == 'enabled':
return 'yes'
return 'no' | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def enforce_tls_requirements(self):
if self._values['enforce_tls_requirements'] is None:
return None
elif self._values['enforce_tls_requirements'] == 'enabled':
return 'yes'
return 'no' | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def __init__(self, want, have=None):
self.want = want
self.have = have | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def __default(self, param):
attr1 = getattr(self.want, param)
try:
attr2 = getattr(self.have, param)
if attr1 != attr2:
return attr1
except AttributeError:
return attr1 | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def description(self):
if self.want.description is None:
return None
if self.want.description == '':
if self.have.description is None or self.have.description == "none":
return None
if self.want.description != self.have.description:
return self... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def __init__(self, *args, **kwargs):
self.module = kwargs.get('module', None)
self.client = F5RestClient(**self.module.params)
self.want = ModuleParameters(params=self.module.params)
self.have = ApiParameters()
self.changes = UsableChanges() | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def _update_changed_options(self):
diff = Difference(self.want, self.have)
updatables = Parameters.updatables
changed = dict()
for k in updatables:
change = diff.compare(k)
if change is None:
continue
else:
if isinstance... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def _announce_deprecations(self, result):
warnings = result.pop('__warnings', [])
for warning in warnings:
self.client.module.deprecate(
msg=warning['msg'],
version=warning['version']
) | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def absent(self):
if self.exists():
return self.remove()
return False | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def should_update(self):
result = self._update_changed_options()
if result:
return True
return False | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def create(self):
self._set_changed_options()
if self.module.check_mode:
return True
self.create_on_device()
return True | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def create_on_device(self):
params = self.changes.api_params()
params['name'] = self.want.name
params['partition'] = self.want.partition
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/http2/".format(
self.client.provider['server'],
self.client.provider['server_port']
... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def remove_from_device(self):
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/http2/{2}".format(
self.client.provider['server'],
self.client.provider['server_port'],
transform_name(self.want.partition, self.want.name)
)
response = self.client.api.delete(uri)
... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def __init__(self):
self.supports_check_mode = True
argument_spec = dict(
name=dict(required=True),
parent=dict(),
activation_modes=dict(
type='list',
elements='str',
choices=[
'alpn', 'always'
... | F5Networks/f5-ansible-modules | [
357,
221,
357,
48,
1448045671
] |
def __init__(self):
""" Initialize the plugin list """
self.__plugins = {} | nacx/kahuna | [
12,
8,
12,
1,
1314873676
] |
def call(self, plugin_name, command_name, args):
""" Encapsulate the call into a context already loaded. """
try:
plugin = self.load_plugin(plugin_name)
except KeyError:
# Plugin not found, pring generic help
self.help_all()
if not command_name:
... | nacx/kahuna | [
12,
8,
12,
1,
1314873676
] |
def help_all(self):
""" Prints the help for all registered plugins """
for name in sorted(__all__):
plugin = self.load_plugin(name)
self.help(plugin)
print | nacx/kahuna | [
12,
8,
12,
1,
1314873676
] |
def __init__(self):
"""
Create Cache object and get thread namespace.
"""
self.namespace = THREAD_NAMESPACE | PeRDy/django-audit-tools | [
8,
3,
8,
1,
1451763432
] |
def set_process(self, process):
"""
Set current process.
:param process: Process object:
:type process: :class:`audit_tools.audit.Process`
"""
self.namespace.audit_current_process = process | PeRDy/django-audit-tools | [
8,
3,
8,
1,
1451763432
] |
def set_last_access(self, access):
"""
Set last access.
:param access: Access object.
:type access: :class:`audit_tools.audit.Access`
"""
self.namespace.audit_current_access = access | PeRDy/django-audit-tools | [
8,
3,
8,
1,
1451763432
] |
def init_ou_structure(self):
# Change from original: Drop OUs outside self.root_ou_id subtree.
super(RandsoneOrgLdif, self).init_ou_structure()
ous, tree = [self.root_ou_id], self.ou_tree
for ou in ous:
ous.extend(tree.get(ou, ()))
self.ou_tree = dict((ou, tree[ou]) f... | unioslo/cerebrum | [
9,
3,
9,
40,
1396362121
] |
def init_person_titles(self):
self.person_titles = {} | unioslo/cerebrum | [
9,
3,
9,
40,
1396362121
] |
def __init__(self, pdata, dbstate, uistate, nav_group=0):
GeoGraphyView.__init__(self, _('Family places map'),
pdata, dbstate, uistate,
FamilyBookmarks,
nav_group)
self.dbstate = dbstate
self.uistate = u... | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def get_stock(self):
"""
Returns the name of the stock icon to use for the display.
This assumes that this icon has already been registered
as a stock icon.
"""
return 'geo-show-family' | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def additional_ui(self):
"""
Specifies the UIManager XML code that defines the menus and buttons
associated with the interface.
"""
return _UI_DEF | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def goto_handle(self, handle=None):
"""
Rebuild the tree with the given person handle as the root.
"""
if self.osm is None:
return
if self.uistate.get_active('Family'):
self._createmap(self.uistate.get_active('Family'))
else:
self._crea... | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def _createpersonmarkers(self, dbstate, person, comment, fam_id):
"""
Create all markers for the specified person.
"""
self.cal = config.get('preferences.calendar-format-report')
latitude = longitude = ""
if person:
# For each event, if we have a place, set a ... | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def _createmap_for_one_family(self, family):
"""
Create all markers for one family : all event's places with a lat/lon.
"""
dbstate = self.dbstate
self.message_layer.add_message(
_("Family places for %s") % self.family_label(family))
person = None
if f... | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def add_event_bubble_message(self, event, lat, lon, mark, menu):
"""
Add an item to the popup menu.
"""
self.itemoption = Gtk.Menu()
itemoption = self.itemoption
itemoption.show()
menu.set_submenu(itemoption)
modify = Gtk.MenuItem(label=_("Edit Family"))
... | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def add_specific_menu(self, menu, event, lat, lon):
"""
Add specific entry to the navigation menu.
"""
return | gramps-project/gramps | [
1698,
344,
1698,
81,
1420599108
] |
def run(emparts, config):
global pv_debug
global pv_last_update
global pv_data
# Only update every X seconds
if time.time() < pv_last_update + int(config.get('min_update', 20)):
if (pv_debug > 1):
print("pv: data skipping")
return
pv_last_update = time.time()
re... | datenschuft/SMA-EM | [
66,
33,
66,
11,
1430946296
] |
def on_publish(client, userdata, result):
pass | datenschuft/SMA-EM | [
66,
33,
66,
11,
1430946296
] |
def __init__(self, flag_name, short_flag, checkbox):
if not flag_name.startswith('re.'):
raise ValueError('Invalid flag name {!r}'.format(flag_name))
self.flagName = flag_name
self.reFlag = getattr(re, flag_name[3:])
self.shortFlag = short_flag
self.checkBox = checkb... | luksan/kodos | [
19,
12,
19,
5,
1263750837
] |
def embed(self):
"""Set the state of the checkbox to show that it
is set by the regexp text."""
if self.preEmbedState == None:
self.preEmbedState = self.checkBox.isChecked()
self.checkBox.setChecked(True)
self.checkBox.setDisabled(True)
return | luksan/kodos | [
19,
12,
19,
5,
1263750837
] |
def allFlagsORed(self):
ret = 0
for f in self:
if f.checkBox.isChecked():
ret |= f.reFlag
return ret | luksan/kodos | [
19,
12,
19,
5,
1263750837
] |
def clear_cache(index, cache):
print "clear cache", index
for tmp in cache:
client[db_name][coll_name_list[index]+"_matrix"].insert(cache[tmp]) | whodewho/FluxEnder | [
21,
11,
21,
1,
1399520247
] |
def extract_ip_feature(index):
model = init_dga()
cursor = client[db_name][coll_name_list[index]].find(timeout=False)
cache = {}
print index
for row in cursor:
if not ip_p.match(str(row["_id"])):
continue
number = len(row["ITEMS"])
min_ttl = min(row["TTLS"])
... | whodewho/FluxEnder | [
21,
11,
21,
1,
1399520247
] |
def list_programs(plugin, item_id, **kwargs):
program_title = 'Le dernier JT'
program_url = URL_ROOT + '/category/jt-complet/'
item = Listitem()
item.label = program_title
item.set_callback(list_videos,
item_id=item_id,
program_url=program_url,
... | Catch-up-TV-and-More/plugin.video.catchuptvandmore | [
225,
76,
225,
57,
1487096995
] |
def list_communes(plugin, item_id, program_url, page, **kwargs):
return False | Catch-up-TV-and-More/plugin.video.catchuptvandmore | [
225,
76,
225,
57,
1487096995
] |
def list_videos(plugin, item_id, program_url, page, **kwargs):
if page == '1':
resp = urlquick.get(program_url)
else:
resp = urlquick.get(program_url + 'page/%s/' % page)
root = resp.parse()
for video_datas in root.iterfind(".//article"):
if video_datas.find(".//h2") is not Non... | Catch-up-TV-and-More/plugin.video.catchuptvandmore | [
225,
76,
225,
57,
1487096995
] |
def get_video_url(plugin,
item_id,
video_url,
download_mode=False,
**kwargs):
resp = urlquick.get(video_url)
if len(re.compile(r'source src\=\"(.*?)\"').findall(resp.text)) > 0:
stream_url = re.compile(
r'source src\=\... | Catch-up-TV-and-More/plugin.video.catchuptvandmore | [
225,
76,
225,
57,
1487096995
] |
def main():
print('Welcome to the ScrapeBot setup')
config = get_config()
instance_name = check_minimal_config(config)
print('Continuing to the database')
print('- connecting to ' + config.get('Database', 'host', fallback='localhost'))
try:
engine = get_engine(config)
base.meta... | MarHai/ScrapeBot | [
16,
5,
16,
3,
1423476441
] |
def get_config(create_if_necessary=True):
if not os.access('config.ini', os.R_OK) and create_if_necessary:
config = setup_config()
print('Reading newly created config.ini')
return config
elif not os.access('config.ini', os.R_OK):
print('Configuration (config.ini) not found (have ... | MarHai/ScrapeBot | [
16,
5,
16,
3,
1423476441
] |
def read_forcefully(line, default=''):
if default != '':
line = line + ' (default is "' + default + '", to accept just hit return)'
value = input(line + ': ').strip()
if value == '':
if default == '':
print('- This information is obligatory!')
return read_forcefully(l... | MarHai/ScrapeBot | [
16,
5,
16,
3,
1423476441
] |
def read_numeric_forcefully(line, default=None):
if default != '':
line = line + ' (default is ' + str(default) + ', to accept just hit return)'
value = input(line + ': ').strip()
if value == '':
if default is None:
print('- This information is really necessary, please enter a nu... | MarHai/ScrapeBot | [
16,
5,
16,
3,
1423476441
] |
def get_engine(config):
database_timeout = -1
try:
database_timeout = int(config.get('Database', 'Timeout', fallback=-1))
if database_timeout > 0:
print('Reconnecting to MySQL (through SQLAlchemy\'s pool_recycle) every ' + str(database_timeout) +
' seconds')
exc... | MarHai/ScrapeBot | [
16,
5,
16,
3,
1423476441
] |
def genDictFromFreq(freq_dict, size_b):
"""
Creates a LZ77 dictionary (initial lookback window) from a dictionary of
word: frequency
Args:
freq_dict (dict(str)): A dictionary mapping word to frequency
size_b (int): output size of frequency dictionary in B
Returns:
st... | pinterest/mysql_utils | [
877,
144,
877,
1,
1445707999
] |
def main():
args = parse()
with open(args.freqs_file, 'r') as freqs_file:
counts = json.load(freqs_file)
# Generate Dictionary from substring frequencies
zdict_str = genDictFromFreq(counts, args.size)
print(zdict_str, end='') | pinterest/mysql_utils | [
877,
144,
877,
1,
1445707999
] |
def setup():
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
GPIO.setup(Gpin, GPIO.OUT) # Set Green Led Pin mode to output
GPIO.setup(Rpin, GPIO.OUT) # Set Red Led Pin mode to output
GPIO.setup(TouchPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Set BtnPin's mode is input, and pull up to h... | sunfounder/SunFounder_SensorKit_for_RPi2 | [
105,
84,
105,
15,
1440128194
] |
def Print(x):
global tmp
if x != tmp:
if x == 0:
print (' **********')
print (' * ON *')
print (' **********') | sunfounder/SunFounder_SensorKit_for_RPi2 | [
105,
84,
105,
15,
1440128194
] |
def loop():
while True:
Led(GPIO.input(TouchPin))
Print(GPIO.input(TouchPin)) | sunfounder/SunFounder_SensorKit_for_RPi2 | [
105,
84,
105,
15,
1440128194
] |
def main(inargs=None):
import argparse
import Cerebrum.logutils
import Cerebrum.logutils.options
parser = argparse.ArgumentParser(
description="Start flask dev server",
)
bind_opts = parser.add_argument_group('bind options')
bind_opts.add_argument(
'--host',
default... | unioslo/cerebrum | [
9,
3,
9,
40,
1396362121
] |
def identity_matrix():
return numpy.require(_identity_matrix[:], 'f') | dkobozev/tatlin | [
48,
16,
48,
2,
1320015854
] |
def translate(vertices, x, y, z):
translated = vertices + numpy.array([x, y, z], 'f')
return translated | dkobozev/tatlin | [
48,
16,
48,
2,
1320015854
] |
def __init__(self, tot=100, lenght=10):
self.cp='/-\|'
self.bar_lenght = lenght
self.tot = tot | luca-heltai/ePICURE | [
10,
23,
10,
12,
1416839855
] |
def progress(self, x):
"""Sets progress bar to a certain percentage x.
Progress is given as whole percentage, i.e. 50% done
is given by x = 50"""
y = int(x)%4
z = int((x/float(self.tot))*self.bar_lenght)
sys.stdout.write("#" * z + self.cp[y] +"-" * (self.bar_lenght-1 - z) + "] "+ bold... | luca-heltai/ePICURE | [
10,
23,
10,
12,
1416839855
] |
def __init__(self):
self.COLS = struct.unpack('hh', fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, '1234'))[1] | luca-heltai/ePICURE | [
10,
23,
10,
12,
1416839855
] |
def _glib_sigint_handler(cls, user_data):
context = cls._loop_contexts[-1]
context._quit_by_sigint = True
context._loop_exit_func()
# keep the handler around until we explicitly remove it
return True | exaile/exaile | [
332,
82,
332,
90,
1409354815
] |
def __enter__(self):
# Only use unix_signal_add if this is not win32 and there has
# not already been one.
if sys.platform != 'win32' and not InterruptibleLoopContext._loop_contexts:
# Add a glib signal handler
source_id = GLib.unix_signal_add(
GLib.PRIORI... | exaile/exaile | [
332,
82,
332,
90,
1409354815
] |
def __init__(self, init_type, init_args, patch, scope, name):
Processor.__init__(self, 2, 1, init_type, init_args, patch, scope, name)
initargs, kwargs = self.parse_args(init_args)
if len(initargs):
self.mapname = initargs[0]
else:
self.mapname = "semitone"
... | bgribble/mfp | [
49,
2,
49,
39,
1357664703
] |
def __init__(self, label_time):
self.label_time = label_time
style_context = self.label_time.get_style_context()
self.color_override = Gtk.CssProvider()
style_context.add_provider(self.color_override, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1)
self.label_color_default = self.... | Cimbali/pympress | [
820,
75,
820,
22,
1442468502
] |
def default_color(self):
""" Forces to reset the default colors on the label.
"""
self.color_override.load_from_data(''.encode('ascii')) | Cimbali/pympress | [
820,
75,
820,
22,
1442468502
] |
def __init__(self, builder, ett, timing_tracker, autoplay):
super(TimeCounter, self).__init__()
self.label_colorer = TimeLabelColorer(builder.get_object('label_time'))
self.ett = ett
self.timing_tracker = timing_tracker
self.autoplay = autoplay
builder.load_widgets(self... | Cimbali/pympress | [
820,
75,
820,
22,
1442468502
] |
def pause(self):
""" Pause the timer if it is not paused, otherwise do nothing.
Returns:
`bool`: whether the clock's pause was toggled.
"""
if self.paused:
return False
self.paused = True
self.pause_action.change_state(GLib.Variant.new_boolean(se... | Cimbali/pympress | [
820,
75,
820,
22,
1442468502
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.