function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def setUp(self):
"""
Initialize account and pages.
"""
super(AccountSettingsPageTest, self).setUp()
self.username, self.user_id = self.log_in_as_unique_user()
self.visit_account_settings_page() | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_all_sections_and_fields_are_present(self):
"""
Scenario: Verify that all sections and fields are present on the page.
"""
expected_sections_structure = [
{
'title': 'Basic Account Information (required)',
'fields': [
... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def _test_text_field(
self, field_id, title, initial_value, new_invalid_value, new_valid_values, success_message=SUCCESS_MESSAGE,
assert_after_reload=True | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def _test_dropdown_field(
self, field_id, title, initial_value, new_values, success_message=SUCCESS_MESSAGE, reloads_on_save=False | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def _test_link_field(self, field_id, title, link_title, success_message):
"""
Test behaviour a link field.
"""
self.assertEqual(self.account_settings_page.title_for_field(field_id), title)
self.assertEqual(self.account_settings_page.link_title_for_link_field(field_id), link_title... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_full_name_field(self):
"""
Test behaviour of "Full Name" field.
"""
self._test_text_field(
u'name',
u'Full Name',
self.username,
u'@',
[u'another name', self.username],
)
actual_events = self.wait_for_e... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_password_field(self):
"""
Test behaviour of "Password" field.
"""
self._test_link_field(
u'password',
u'Password',
u'Reset Password',
success_message='Click the link in the message to reset your password.',
)
event... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_language_field(self):
"""
Test behaviour of "Language" field.
"""
self._test_dropdown_field(
u'pref-lang',
u'Language',
u'English',
[u'Dummy Language (Esperanto)', u'English'],
reloads_on_save=True,
) | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_gender_field(self):
"""
Test behaviour of "Gender" field.
"""
self._test_dropdown_field(
u'gender',
u'Gender',
u'',
[u'Female', u''],
)
actual_events = self.wait_for_events(event_filter=self.settings_changed_event_... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_country_field(self):
"""
Test behaviour of "Country or Region" field.
"""
self._test_dropdown_field(
u'country',
u'Country or Region',
u'',
[u'Pakistan', u'Palau'],
) | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def test_connected_accounts(self):
"""
Test that fields for third party auth providers exist.
Currently there is no way to test the whole authentication process
because that would require accounts with the providers.
"""
providers = (
['auth-oa2-facebook', 'F... | analyseuc3m/ANALYSE-v1 | [
10,
5,
10,
1,
1460987160
] |
def sync():
try:
_keep_alive_for = int(NS.config.data.get("sync_interval", 10)) + 250
disks = get_node_disks()
disk_map = {}
for disk in disks:
# Creating dict with disk name as key and disk_id as value
# It will help populate block device disk_id attribute
... | Tendrl/node_agent | [
4,
14,
4,
20,
1473351508
] |
def get_disk_details():
disks = {}
disks_map = {}
cmd = cmd_utils.Command('hwinfo --disk')
out, err, rc = cmd.run()
if not err:
out = unicodedata.normalize('NFKD', out).encode('utf8', 'ignore') \
if isinstance(out, unicode) \
else unicode(out, errors="ignore").enco... | Tendrl/node_agent | [
4,
14,
4,
20,
1473351508
] |
def get_raw_reference():
base_path = '/dev/disk/'
paths = os.listdir(base_path)
raw_reference = {}
for path in paths:
raw_reference[path] = []
full_path = base_path + path
cmd = cmd_utils.Command("ls -l %s" % full_path)
out, err, rc = cmd.run()
if not err:
... | Tendrl/node_agent | [
4,
14,
4,
20,
1473351508
] |
def authorized_to_manage_request(_, request, current_user, pushmaster=False):
if pushmaster or \
request['user'] == current_user or \
(request['watchers'] and current_user in request['watchers'].split(',')):
return True
return False | YelpArchive/pushmanager | [
37,
23,
37,
12,
1359009995
] |
def compare_requests(request1, request2):
tags1_list = request1['tags'].split(',')
tags2_list = request2['tags'].split(',')
for tag in tags_order:
tag_in_tags1 = tag in tags1_list
tag_in_tags2 = tag in tags2_list
if tag_in_tags1 == tag_in_tags2:
... | YelpArchive/pushmanager | [
37,
23,
37,
12,
1359009995
] |
def __init__(self):
self.instances_by_id = {}
self.ids_by_uuid = {}
self.max_id = 0 | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def return_server_by_uuid(self, context, uuid):
if uuid not in self.ids_by_uuid:
self._add_server(uuid=uuid)
return dict(self.instances_by_id[self.ids_by_uuid[uuid]]) | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def stub_instance(id, user_id='fake', project_id='fake', host=None,
vm_state=None, task_state=None,
reservation_id="", uuid=FAKE_UUID, image_ref="10",
flavor_id="1", name=None, key_name='',
access_ipv4=None, access_ipv6=None, progress=0):
if h... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def setUp(self):
super(ConsolesControllerTest, self).setUp()
self.flags(verbose=True)
self.instance_db = FakeInstanceDB()
self.stubs.Set(db, 'instance_get',
self.instance_db.return_server_by_id)
self.stubs.Set(db, 'instance_get_by_uuid',
... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def fake_create_console(cons_self, context, instance_id):
self.assertEqual(instance_id, self.uuid)
return {} | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def test_show_console(self):
def fake_get_console(cons_self, context, instance_id, console_id):
self.assertEqual(instance_id, self.uuid)
self.assertEqual(console_id, 20)
pool = dict(console_type='fake_type',
public_hostname='fake_hostname')
ret... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def fake_get_console(cons_self, context, instance_id, console_id):
raise exception.ConsoleNotFound(console_id=console_id) | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def test_show_console_unknown_instance(self):
def fake_get_console(cons_self, context, instance_id, console_id):
raise exception.InstanceNotFound(instance_id=instance_id)
self.stubs.Set(console.api.API, 'get_console', fake_get_console)
req = fakes.HTTPRequest.blank(self.url + '/20'... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def fake_get_consoles(cons_self, context, instance_id):
self.assertEqual(instance_id, self.uuid)
pool1 = dict(console_type='fake_type',
public_hostname='fake_hostname')
cons1 = dict(id=10, password='fake_password',
port='fake_port', pool=pool1... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def test_delete_console(self):
def fake_get_console(cons_self, context, instance_id, console_id):
self.assertEqual(instance_id, self.uuid)
self.assertEqual(console_id, 20)
pool = dict(console_type='fake_type',
public_hostname='fake_hostname')
r... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def fake_delete_console(cons_self, context, instance_id, console_id):
raise exception.ConsoleNotFound(console_id=console_id) | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def test_delete_console_unknown_instance(self):
def fake_delete_console(cons_self, context, instance_id, console_id):
raise exception.InstanceNotFound(instance_id=instance_id)
self.stubs.Set(console.api.API, 'delete_console', fake_delete_console)
req = fakes.HTTPRequest.blank(self.... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def test_show(self):
fixture = {'console': {'id': 20,
'password': 'fake_password',
'port': 'fake_port',
'host': 'fake_hostname',
'console_type': 'fake_type'}}
output = consoles.Co... | josephsuh/extra-specs | [
1,
1,
1,
1,
1337971331
] |
def __init__(self, context, core):
self._context = context
self._core = core
self._run_token = -1
self._reset_cache() | pyocd/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def _dump_metrics(self):
if self._metrics.total > 0:
LOG.debug("%d reads [%d%% hits, %d regs]", self._metrics.total, self._metrics.percent_hit, self._metrics.hits)
else:
LOG.debug("no accesses") | pyocd/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def _convert_and_check_registers(self, reg_list):
# convert to index only
reg_list = [index_for_reg(reg) for reg in reg_list]
self._core.check_reg_list(reg_list)
return reg_list | pyocd/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def write_core_registers_raw(self, reg_list, data_list):
# Check and invalidate the cache. If the core is still running, just pass the writes
# to our context.
if self._check_cache():
self._context.write_core_registers_raw(reg_list, data_list)
return
reg_list = s... | pyocd/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def _get_model(shape, axis, keepdims, input_zp, input_sc, output_zp, output_sc, dtype):
a = relay.var("a", shape=shape, dtype=dtype)
casted = relay.op.cast(a, "int32")
mean = relay.mean(casted, axis, keepdims)
model = relay.qnn.op.requantize(
mean,
input_scale=relay.const(input_sc, "floa... | dmlc/tvm | [
9142,
2938,
9142,
595,
1476310828
] |
def difftree(ui, repo, node1=None, node2=None, *files, **opts):
"""diff trees from two commits"""
def __difftree(repo, node1, node2, files=[]):
assert node2 is not None
mmap = repo[node1].manifest()
mmap2 = repo[node2].manifest()
m = cmdutil.match(repo, files)
modified, a... | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def base(ui, repo, node1, node2):
"""output common ancestor information"""
node1 = repo.lookup(node1)
node2 = repo.lookup(node2)
n = repo.changelog.ancestor(node1, node2)
ui.write(short(n) + "\n") | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def revtree(ui, args, repo, full="tree", maxnr=0, parents=False):
def chlogwalk():
count = len(repo)
i = count
l = [0] * 100
chunk = 100
while True:
if chunk > i:
chunk = i
i = 0
else:
i -= chunk
... | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def revstr(rev):
if rev == 'HEAD':
rev = 'tip'
return revlog.hex(repo.lookup(rev)) | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def revlist(ui, repo, *revs, **opts):
"""print revisions"""
if opts['header']:
full = "commit"
else:
full = None
copy = [x for x in revs]
revtree(ui, copy, repo, full, opts['max_count'], opts['parents']) | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def writeopt(name, value):
ui.write('k=%s\nv=%s\n' % (name, value)) | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def view(ui, repo, *etc, **opts):
"start interactive history viewer"
os.chdir(repo.root)
optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v])
cmd = ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc))
ui.debug("running %s\n" % cmd)
util.system(cmd) | joewalnes/idea-community | [
33,
38,
33,
5,
1296022956
] |
def _deweird(s):
"""
Sometimes numpy loadtxt returns strings like "b'stuff'"
This converts them to "stuff"
@ In, s, str, possibly weird string
@ Out, _deweird, str, possibly less weird string
"""
if type(s) == str and s.startswith("b'") and s.endswith("'"):
return s[2:-1]
else:
return s | idaholab/raven | [
168,
104,
168,
215,
1490297367
] |
def __init__(self, outFiles):
"""
Initialize the class
@ In, outFiles, list, list of output files of SAPHIRE
@ Out, None
"""
self.headerNames = [] # list of variable names in SAPHIRE output files
self.outData = [] # list of variable values in SAPHIRE output files
for outFile in... | idaholab/raven | [
168,
104,
168,
215,
1490297367
] |
def getImportance(self, outName):
"""
Method to extract the importance information of Fault Tree from SAPHIRE output files
@ In, outName, string, the name of output file
@ Out, headerNames, list, list of output variable names
@ Out, outData, list, list of output variable values
"""
h... | idaholab/raven | [
168,
104,
168,
215,
1490297367
] |
def setUp(self):
self.assertTrue(th.SetupTestDB())
self.db_path = th.TEST_DB_PATH
self.dba = DBAccess(db_path=self.db_path)
self.conn = sqlite3.connect(self.db_path)
self.cursor = self.conn.cursor() | ScienceStacks/JViz | [
30,
5,
30,
7,
1435851901
] |
def testmaketable(self):
CLIENT_URL = '/heatmap/maketable/'
TABLE_LIST = ['data_rev', 'data']
response = self.client.get(CLIENT_URL)
self.assertEqual(response.status_code, 200)
form_data = {'numrows': 10, 'lastrow': 1}
form = TableForm(data=form_data)
post_dict = {'display_form': form,
... | ScienceStacks/JViz | [
30,
5,
30,
7,
1435851901
] |
def testQuery(self):
CLIENT_URL = '/heatmap/query/'
TABLE_LIST = ['data_rev', 'data']
TABLE_NAME = "testQuery"
response = self.client.get(CLIENT_URL)
self.assertEqual(response.status_code, 200)
# Test the post
th.CreateTableWithData(TABLE_NAME, self.conn)
query_string = "SELECT * from %s... | ScienceStacks/JViz | [
30,
5,
30,
7,
1435851901
] |
def __init__(self, auto_describe=False):
self._collector_to_names = {}
self._names_to_collectors = {}
self._auto_describe = auto_describe
self._lock = Lock() | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def unregister(self, collector):
"""Remove a collector from the registry."""
with self._lock:
for name in self._collector_to_names[collector]:
del self._names_to_collectors[name]
del self._collector_to_names[collector] | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def collect(self):
"""Yields metrics from the collectors in the registry."""
collectors = None
with self._lock:
collectors = copy.copy(self._collector_to_names)
for collector in collectors:
for metric in collector.collect():
yield metric | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def collect(self):
return metrics | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def get_sample_value(self, name, labels=None):
"""Returns the sample value, or None if not found.
This is inefficient, and intended only for use in unittests.
"""
if labels is None:
labels = {}
for metric in self.collect():
for s in metric.samples:
... | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def testDerCodec(self):
layers = { }
layers.update(rfc5652.cmsContentTypesMap)
getNextLayer = {
rfc5652.id_ct_contentInfo: lambda x: x['contentType'],
rfc5652.id_signedData: lambda x: x['encapContentInfo']['eContentType'],
rfc6402.id_cct_PKIData: lambda x: No... | etingof/pyasn1-modules | [
38,
39,
38,
8,
1456353005
] |
def interface(name, file=None):
return Spec({name: []}) | serge-sans-paille/pythran | [
1865,
184,
1865,
122,
1338278534
] |
def extract_runas(name, filepath):
return ['#runas {}()'.format(name)] | serge-sans-paille/pythran | [
1865,
184,
1865,
122,
1338278534
] |
def interface(name, file=None):
return Spec({name: []}) | serge-sans-paille/pythran | [
1865,
184,
1865,
122,
1338278534
] |
def extract_runas(name, filepath):
return ['#runas {}()'.format(name)] | serge-sans-paille/pythran | [
1865,
184,
1865,
122,
1338278534
] |
def y2k():
return datetime(2000, 1, 1).replace(tzinfo=utc) | gregmuellegger/django-autofixture | [
458,
114,
458,
30,
1282675169
] |
def __init__(self, address=None, value=None, **kwargs):
""" Initializes a new instance
:param address: The variable address to write
:param value: The value to write at address
"""
ModbusRequest.__init__(self, **kwargs)
self.address = address
self.value = bool(va... | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def decode(self, data):
""" Decodes a write coil request
:param data: The packet data to decode
"""
self.address, value = struct.unpack('>HH', data)
self.value = (value == ModbusStatus.On) | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def __str__(self):
""" Returns a string representation of the instance
:return: A string representation of the instance
"""
return 'WriteCoilRequest({0}, {1}) => '.format(
self.address, self.value
) | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def __init__(self, address=None, value=None, **kwargs):
""" Initializes a new instance
:param address: The variable address written to
:param value: The value written at address
"""
ModbusResponse.__init__(self, **kwargs)
self.address = address
self.value = value | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def decode(self, data):
""" Decodes a write coil response
:param data: The packet data to decode
"""
self.address, value = struct.unpack('>HH', data)
self.value = (value == ModbusStatus.On) | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def __init__(self, address=None, values=None, **kwargs):
""" Initializes a new instance
:param address: The starting request address
:param values: The values to write
"""
ModbusRequest.__init__(self, **kwargs)
self.address = address
if not values:
va... | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def decode(self, data):
""" Decodes a write coils request
:param data: The packet data to decode
"""
self.address, count, self.byte_count = struct.unpack('>HHB', data[0:5])
values = unpack_bitstring(data[5:])
self.values = values[:count] | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def __str__(self):
""" Returns a string representation of the instance
:returns: A string representation of the instance
"""
return 'WriteMultipleCoilRequest ({0}) => {1} '.format(
self.address, len(self.values)
) | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def __init__(self, address=None, count=None, **kwargs):
""" Initializes a new instance
:param address: The starting variable address written to
:param count: The number of values written
"""
ModbusResponse.__init__(self, **kwargs)
self.address = address
self.coun... | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def decode(self, data):
""" Decodes a write coils response
:param data: The packet data to decode
"""
self.address, self.count = struct.unpack('>HH', data) | uzumaxy/pymodbus3 | [
34,
11,
34,
3,
1405577525
] |
def wrap_http_connection(http_connection=None):
if not http_connection:
http_connection = requests.Session() if requests else httplib2.Http()
if not is_requests_instance(http_connection):
http_connection = RequestWrapper(http_connection)
return http_connection | tow/sunburnt | [
278,
89,
278,
30,
1248440645
] |
def __init__(self, conn):
self.conn = conn | tow/sunburnt | [
278,
89,
278,
30,
1248440645
] |
def publish_github_release(slug, token, tag_name, body):
github = github3.login(token=token)
owner, repo = slug.split("/")
repo = github.repository(owner, repo)
return repo.create_release(tag_name=tag_name, body=body) | pytest-dev/pytest | [
9887,
2273,
9887,
850,
1434400107
] |
def convert_rst_to_md(text):
return pypandoc.convert_text(
text, "md", format="rst", extra_args=["--wrap=preserve"]
) | pytest-dev/pytest | [
9887,
2273,
9887,
850,
1434400107
] |
def theme_config_init():
"""Initialization of configuration file. Sections: ???."""
global theme_config_file, theme_config_option
theme_config_file = weechat.config_new(THEME_CONFIG_FILE_NAME,
'theme_config_reload_cb', '')
if not theme_config_file:
retu... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_config_reload_cb(data, config_file):
"""Reload configuration file."""
return weechat.config_read(config_file) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_config_write():
"""Write configuration file."""
global theme_config_file
return weechat.config_write(theme_config_file) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_config_get_dir():
"""Return themes directory, with expanded WeeChat home dir."""
global theme_config_option
return weechat.config_string(
theme_config_option['themes_dir']).replace('%h',
weechat.info_get('weechat_dir', '')) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_config_get_undo():
"""Return name of undo file (by default "~/.weechat/themes/_undo.theme")."""
return '%s/_undo.theme' % theme_config_get_dir() | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_config_get_cache_filename():
"""Get local cache filename, based on URL."""
global theme_config_option
return '%s/%s' % (theme_config_get_dir(),
os.path.basename(weechat.config_string(theme_config_option['scripts_url']))) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def __init__(self, filename=None):
self.filename = filename
self.props = {}
self.listprops = []
self.options = {}
self.theme_ok = True
if self.filename:
self.theme_ok = self.load(self.filename)
else:
self.init_weechat()
self.nick_pr... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def _option_is_used(self, option):
global theme_options_include_re, theme_options_exclude_re
for regex in theme_options_exclude_re:
if re.search(regex, option):
return False
for regex in theme_options_include_re:
if re.search(regex, option):
... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def _get_attr_color(self, color):
"""Return tuple with attributes and color."""
m = re.match('([*_!]*)(.*)', color)
if m:
return m.group(1), m.group(2)
return '', color | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def _replace_color_alias(self, match):
value = match.group()[2:-1]
if value in self.palette:
value = self.palette[value]
return '${%s}' % value | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def prnt(self, message):
try:
weechat.prnt('', message)
except:
print(message) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def load(self, filename):
self.options = {}
try:
lines = open(filename, 'rb').readlines()
for line in lines:
line = str(line.strip().decode('utf-8'))
if line.startswith('#'):
m = re.match('^# \\$([A-Za-z]+): (.*)', line)
... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def show(self, header):
"""Display content of theme."""
names = self.options.keys()
names.sort()
self.prnt('')
self.prnt(header)
for name in names:
self.prnt(' %s %s= %s%s' % (name, weechat.color('chat_delimiters'),
we... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def install(self):
try:
numset = 0
numerrors = 0
for name in self.options:
option = weechat.config_get(name)
if option:
if weechat.config_option_set(option, self.options[name], 1) == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def __init__(self, filename=None, chat_width=85, chat_height=25, prefix_width=10, nicklist_width=10):
Theme.__init__(self, filename)
self.chat_width = chat_width
self.chat_height = chat_height
self.prefix_width = prefix_width
self.nicklist_width = nicklist_width | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def html_style(self, fg, bg):
"""Return HTML style with WeeChat fg and bg colors."""
weechat_basic_colors = {
'default': 7, 'black': 0, 'darkgray': 8, 'red': 1, 'lightred': 9,
'green': 2, 'lightgreen': 10, 'brown': 3, 'yellow': 11, 'blue': 4,
'lightblue': 12, 'magenta... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def html_nick(self, nicks, index, prefix, usecolor, highlight, maxlen, optfg='fg', optbg='bg'):
"""Print a nick."""
nick = nicks[index]
nickfg = optfg
if usecolor and optfg != 'weechat.color.nicklist_away':
nick_colors = self.options['weechat.color.chat_nick_colors'].split(',... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def _html_apply_colors(self, match):
string = match.group()
end = string.find('}')
if end < 0:
return string
color = string[2:end]
text = string[end + 1:]
return self.html_string(text, 0, color) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def html_chat_time(self, msgtime):
"""Return formatted time with colors."""
option = 'weechat.look.buffer_time_format'
if self.options[option].find('${') >= 0:
str_without_colors = re.sub(r'\$\{[^\}]+\}', '', self.options[option])
length = len(time.strftime(str_without_co... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def to_html(self):
"""Print HTML version of theme."""
self.html_nick_self = 'mario'
channel = '#weechat'
oldtopic = 'Welcome'
newtopic = 'Welcome to %s - help channel for WeeChat' % channel
nicks = ('@carl', '@jessika', '@louise', '%Melody', '%Diego', '+Max',
... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def save_html(self, filename, whitebg=False):
html = self.get_html(whitebg)
try:
f = open(filename, 'w')
f.write(html)
f.close()
self.prnt('Theme exported as HTML to "%s"' % filename)
except:
self.prnt_error('Error writing HTML to "%s"'... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_cmd(data, buffer, args):
"""Callback for /theme command."""
if args == '':
weechat.command('', '/help %s' % SCRIPT_COMMAND)
return weechat.WEECHAT_RC_OK
argv = args.strip().split(' ', 1)
if len(argv) == 0:
return weechat.WEECHAT_RC_OK
if argv[0] in ('list', 'instal... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_init():
"""Called when script is loaded."""
theme_config_create_dir()
filename = theme_config_get_backup()
if not os.path.isfile(filename):
theme = Theme()
theme.save(filename) | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def theme_cmdline():
if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
theme_cmdline_usage()
elif len(sys.argv) > 1:
if sys.argv[1] in ('-e', '--export'):
if len(sys.argv) < 4:
theme_cmdline_usage()
whitebg = 'white' in sys.argv[4:]
hthe... | posquit0/dotfiles | [
170,
19,
170,
1,
1413121319
] |
def _split_what(what):
"""
Returns a tuple of `frozenset`s of classes and attributes.
"""
return (
frozenset(cls for cls in what if isclass(cls)),
frozenset(cls for cls in what if isinstance(cls, Attribute)),
) | python-attrs/attrs | [
4664,
337,
4664,
119,
1422370861
] |
def include_(attribute, value):
return value.__class__ in cls or attribute in attrs | python-attrs/attrs | [
4664,
337,
4664,
119,
1422370861
] |
def setup(self):
self.app = bountyfunding.app.test_client()
clean_database() | bountyfunding/bountyfunding | [
11,
4,
11,
1,
1372027522
] |
def test_email(self):
eq_(len(self.get_emails()), 0) | bountyfunding/bountyfunding | [
11,
4,
11,
1,
1372027522
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.