function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def get_value( self, trans, grid, repository_metadata ):
datatypes_str = '0'
if repository_metadata:
metadata = repository_metadata.metadata
if metadata:
if 'datatypes' in metadata:
# We used to display the following, bu... | mikel-egana-aranguren/SADI-Galaxy-Docker | [
1,
3,
1,
1,
1417087373
] |
def get_value( self, trans, grid, repository_metadata ):
workflows_str = '0'
if repository_metadata:
metadata = repository_metadata.metadata
if metadata:
if 'workflows' in metadata:
# We used to display the following, bu... | mikel-egana-aranguren/SADI-Galaxy-Docker | [
1,
3,
1,
1,
1417087373
] |
def get_value( self, trans, grid, repository_metadata ):
if repository_metadata.repository.deleted:
return 'yes'
return '' | mikel-egana-aranguren/SADI-Galaxy-Docker | [
1,
3,
1,
1,
1417087373
] |
def get_value( self, trans, grid, repository_metadata ):
if repository_metadata.repository.deprecated:
return 'yes'
return '' | mikel-egana-aranguren/SADI-Galaxy-Docker | [
1,
3,
1,
1,
1417087373
] |
def get_value( self, trans, grid, repository_metadata ):
if repository_metadata.malicious:
return 'yes'
return '' | mikel-egana-aranguren/SADI-Galaxy-Docker | [
1,
3,
1,
1,
1417087373
] |
def shortcut_xml_gen(shortcut_entries):
root = etree.Element("interface")
root.append(create_object_tree(shortcut_entries))
content = etree.tostring(root, xml_declaration=True, encoding="UTF-8",
pretty_print=True)
content = content.decode("UTF-8")
return content | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def objnode(adict):
prefix = "GtkShortcuts"
if not adict["klass"].startswith(prefix):
adict["klass"] = prefix + adict["klass"]
if "attrib" not in adict:
adict["attrib"]= {}
aobj = etree.Element ("object", attrib=adict["attrib"])
aobj.attrib["class"] = adic... | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def append_props(parent, item):
if "properties" in item:
props = [propnode(x, y) for x, y in item["properties"].items()]
[parent.append(x) for x in props] | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def shortcut_entry(title, accel=None, gesture=None, **kwargs):
props = { "title": title, "visible": 1, }
if accel:
props["accelerator"] = accel
if gesture:
props["shortcut-type"] = gesture
props.update(kwargs)
entry = {
"klass": "Shortcut",
"properties": props... | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def section_entry(name, groups, **kwargs):
entry = {
"klass": "Section",
"properties": {
"visible": 1,
"section-name": name,
},
"childs": groups,
}
entry["properties"].update(kwargs)
return entry | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def main():
def set_stdio_encoding(enc=NATIVE):
import codecs; stdio = ["stdin", "stdout", "stderr"]
for x in stdio:
obj = getattr(sys, x)
if not obj.encoding: setattr(sys, x, codecs.getwriter(enc)(obj))
set_stdio_encoding()
log_level = log.INFO
log.basicConfig(... | mozbugbox/liferea-plugin-studio | [
6,
3,
6,
6,
1428496840
] |
def test_stream_type_parsing():
"""Make sure we can parse each type of stream."""
# Make sure parsing stream type works
stream = DataStream.FromString('buffered 1')
assert stream.stream_type == stream.BufferedType
stream = DataStream.FromString(u'buffered 1')
assert stream.stream_type == stream... | iotile/coretools | [
13,
7,
13,
230,
1479861690
] |
def test_system_parsing():
"""Make sure we can parse the system prefix."""
stream = DataStream.FromString('buffered 1')
assert stream.system is False
stream = DataStream.FromString(u'buffered 1')
assert stream.system is False
stream = DataStream.FromString('system buffered 1')
assert strea... | iotile/coretools | [
13,
7,
13,
230,
1479861690
] |
def test_selector_parsing():
"""Make sure we can parse DataStreamSelector strings."""
# Make sure parsing stream type works
stream = DataStreamSelector.FromString('buffered 1')
assert stream.match_type == DataStream.BufferedType
stream = DataStreamSelector.FromString(u'buffered 1')
assert strea... | iotile/coretools | [
13,
7,
13,
230,
1479861690
] |
def test_matching():
"""Test selector stream matching."""
sel = DataStreamSelector.FromString(u'all system buffered')
assert sel.matches(DataStream.FromString('system buffered 1'))
assert not sel.matches(DataStream.FromString('buffered 1'))
assert not sel.matches(DataStream.FromString('counter 1'))... | iotile/coretools | [
13,
7,
13,
230,
1479861690
] |
def test_selector_from_encoded():
"""Make sure we can create a selector from an encoded value."""
sel = DataStreamSelector.FromEncoded(0x5FFF)
assert str(sel) == 'all system outputs'
sel = DataStreamSelector.FromEncoded(0xD7FF)
assert str(sel) == 'all outputs'
sel = DataStreamSelector.FromEnc... | iotile/coretools | [
13,
7,
13,
230,
1479861690
] |
def formatCase(text):
"""Formats code to contain only one indentation and terminate with a \n"""
return indent(dedent(text.lstrip("\n")), " ") + "\n" | ethereum/solidity | [
19651,
4867,
19651,
712,
1439814446
] |
def setUp(self):
self.maxDiff = 10000 | ethereum/solidity | [
19651,
4867,
19651,
712,
1439814446
] |
def test_solidity_block_with_directives(self):
expected_cases = [formatCase(case) for case in [
"""
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract C {
function foo() public view {}
}
... | ethereum/solidity | [
19651,
4867,
19651,
712,
1439814446
] |
def register_field(name):
"""add resolver class to registry"""
def add_class(clazz):
field_registry[name] = clazz
return clazz
return add_class | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def __init__(self, key, props):
self.key = key
self.props = props | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def create(key, context):
# normalize
if isinstance(context, str):
context = {
"lookup": "literal",
"prop": {
"value": context
}
}
field_type = context["lookup"]
... | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def __init__(self, key, props):
super().__init__(key, props) | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def value(self):
return self.props["value"] | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def __init__(self, key, props):
super().__init__(key, props) | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def value(self):
return os.environ[self.props["variable"]] | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def __init__(self, key, props):
super().__init__(key, props) | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def value(self):
return self.resolver.get(
self.props["value"],
self.props.get("index", None)
) | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def provider(self):
provider_manager = ProviderManager.instance()
return provider_manager.get(self.props["provider"]) | 2pisoftware/cmfive-boilerplate | [
1,
10,
1,
3,
1485729376
] |
def setupUi(self, CanardPreferencesDialog):
CanardPreferencesDialog.setObjectName(_fromUtf8("CanardPreferencesDialog"))
CanardPreferencesDialog.resize(512, 375)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/actions/preferences-system-2.png")), QtGui.QIcon.Normal, Q... | LegoStormtroopr/canard | [
13,
4,
13,
10,
1368350533
] |
def setup():
print("SETUP") | nanounanue/pipeline-template | [
5,
8,
5,
1,
1489206972
] |
def formatFrameToTime(start, current, frameRate):
total = current - start
seconds = float(total) / float(frameRate)
minutes = int(seconds / 60.0)
seconds -= minutes * 60
return ":".join(["00", str(minutes).zfill(2),
str(round(seconds, 1)).zfill(2),
str(int(... | dsparrow27/zoocore | [
3,
2,
3,
2,
1485309529
] |
def __init__(self, protocol):
self.protocol = protocol
self.calls = WeakSet()
self.loops = WeakSet() | piqueserver/piqueserver | [
165,
59,
165,
87,
1482889715
] |
def call_end(self, *arg, **kw):
call = self.protocol.call_end(*arg, **kw)
self.calls.add(call)
return call | piqueserver/piqueserver | [
165,
59,
165,
87,
1482889715
] |
def __init__(self, meaning, glue, indices=None):
if not indices:
indices = set() | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def applyto(self, arg):
""" self = (\\x.(walk x), (subj -o f))
arg = (john , subj)
returns ((walk john), f)
"""
if self.indices & arg.indices: # if the sets are NOT disjoint
raise linearlogic.LinearLogicApplicationException, "'%s' applied to ... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def make_VariableExpression(self, name):
return logic.VariableExpression(name) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def make_LambdaExpression(self, variable, term):
return logic.LambdaExpression(variable, term) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def lambda_abstract(self, other):
assert isinstance(other, GlueFormula)
assert isinstance(other.meaning, logic.AbstractVariableExpression)
return self.__class__(self.make_LambdaExpression(other.meaning.variable,
self.meaning),
... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def simplify(self):
return self.__class__(self.meaning.simplify(), self.glue.simplify(), self.indices) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __str__(self):
assert isinstance(self.indices, set)
accum = '%s : %s' % (self.meaning, self.glue)
if self.indices:
accum += ' : {' + ', '.join([str(index) for index in self.indices]) + '}'
return accum | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __repr__(self):
return str(self) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __init__(self, filename):
self.filename = filename
self.read_file() | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def read_file(self, empty_first=True):
if empty_first:
self.clear()
try:
f = nltk.data.find(
os.path.join('grammars', 'sample_grammars', self.filename))
# if f is a ZipFilePathPointer or a FileSystemPathPointer
# then we need a little ext... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __str__(self):
accum = ''
for pos in self:
for relset in self[pos]:
i = 1
for gf in self[pos][relset]:
if i==1:
accum += str(pos) + ': '
else:
accum += ' '*(len(str(pos... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def lookup(self, node, depgraph, counter):
semtype_names = self.get_semtypes(node) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def add_missing_dependencies(self, node, depgraph):
rel = node['rel'].lower() | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def _lookup_semtype_option(self, semtype, node, depgraph):
relationships = frozenset([depgraph.nodelist[dep]['rel'].lower()
for dep in node['deps']
if depgraph.nodelist[dep]['rel'].lower()
not in OPTI... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_semtypes(self, node):
"""
Based on the node, return a list of plausible semtypes in order of
plausibility.
"""
semtype_name = None | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_glueformulas_from_semtype_entry(self, lookup, word, node, depgraph, counter):
glueformulas = []
glueFormulaFactory = self.get_GlueFormula_factory()
for meaning, glue in lookup:
gf = glueFormulaFactory(self.get_meaning_formula(meaning, word), glue)
if not len(glue... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def initialize_labels(self, expr, node, depgraph, unique_index):
if isinstance(expr, linearlogic.AtomicExpression):
name = self.find_label_name(expr.name.lower(), node, depgraph, unique_index)
if name[0].isupper():
return linearlogic.VariableExpression(name)
e... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_label(self, node):
"""
Pick an alphabetic character as identifier for an entity in the model. | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def lookup_unique(self, rel, node, depgraph):
"""
Lookup 'key'. There should be exactly one item in the associated relation.
"""
deps = [depgraph.nodelist[dep] for dep in node['deps']
if depgraph.nodelist[dep]['rel'].lower() == rel.lower()] | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_GlueFormula_factory(self):
return GlueFormula | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __init__(self, semtype_file=None, remove_duplicates=False,
depparser=None, verbose=False):
self.verbose = verbose
self.remove_duplicates = remove_duplicates
self.depparser = depparser | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def train_depparser(self, depgraphs=None):
if depgraphs:
self.depparser.train(depgraphs)
else:
self.depparser.train_from_file(nltk.data.find(
os.path.join('grammars', 'sample_grammars',
'glue_train.conll'))) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def parse_to_meaning(self, sentence):
readings = []
for agenda in self.parse_to_compiled(sentence):
readings.extend(self.get_readings(agenda))
return readings | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_readings(self, agenda):
readings = []
agenda_length = len(agenda)
atomics = dict()
nonatomics = dict()
while agenda: # is not empty
cur = agenda.pop()
glue_simp = cur.glue.simplify()
if isinstance(glue_simp, linearlogic.ImpExpression): ... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def _add_to_reading_list(self, glueformula, reading_list):
add_reading = True
if self.remove_duplicates:
for reading in reading_list:
try:
if reading.equiv(glueformula.meaning, self.prover):
add_reading = False
... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def parse_to_compiled(self, sentence='a man sees Mary'):
gfls = [self.depgraph_to_glue(dg) for dg in self.dep_parse(sentence)]
return [self.gfl_to_compiled(gfl) for gfl in gfls] | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def dep_parse(self, sentence='every cat leaves'):
#Lazy-initialize the depparser
if self.depparser is None:
self.depparser = MaltParser(tagger=self.get_pos_tagger())
if not self.depparser._trained:
self.train_depparser()
return [self.depparser.parse(sentence, ver... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def depgraph_to_glue(self, depgraph):
return self.get_glue_dict().to_glueformula_list(depgraph) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_glue_dict(self):
return GlueDict(self.semtype_file) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def gfl_to_compiled(self, gfl):
index_counter = Counter()
return_list = []
for gf in gfl:
return_list.extend(gf.compile(index_counter)) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_pos_tagger(self):
regexp_tagger = RegexpTagger(
[(r'^-?[0-9]+(.[0-9]+)?$', 'CD'), # cardinal numbers
(r'(The|the|A|a|An|an)$', 'AT'), # articles
(r'.*able$', 'JJ'), # adjectives
(r'.*ness$', 'NN'), # nouns formed from a... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __init__(self, meaning, glue, indices=None):
if not indices:
indices = set()
if isinstance(meaning, str):
self.meaning = drt.DrtParser().parse(meaning)
elif isinstance(meaning, drt.AbstractDrs):
self.meaning = meaning
else:
raise Runti... | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def make_VariableExpression(self, name):
return drt.DrtVariableExpression(name) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def make_LambdaExpression(self, variable, term):
return drt.DrtLambdaExpression(variable, term) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def get_GlueFormula_factory(self):
return DrtGlueFormula | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __init__(self, semtype_file=None, remove_duplicates=False,
depparser=None, verbose=False):
if not semtype_file:
semtype_file = 'drt_glue.semtype'
Glue.__init__(self, semtype_file, remove_duplicates, depparser, verbose) | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def demo(show_example=-1):
examples = ['David sees Mary',
'David eats a sandwich',
'every man chases a dog',
'every man believes a dog sleeps',
'John gives David a sandwich',
'John chases himself'] | markgw/jazzparser | [
5,
1,
5,
1,
1368367354
] |
def __str__(self) -> str:
return str(self.dict()) | declension/squeeze-alexa | [
60,
20,
60,
27,
1483607926
] |
def __init__(self):
# Set the instance-level things:
for k, v in type(self).__dict__.items():
if not k.startswith('_') and k not in Settings.__dict__:
setattr(self, k.lower(), v) | declension/squeeze-alexa | [
60,
20,
60,
27,
1483607926
] |
def human_log(callback, host, res):
if hasattr(res, 'startswith'):
if callback == 'runner_on_unreachable':
print('-----> ERROR: {host} was unreachable'.format(host=host))
print('\n'.join([' %s' % line for line in res.splitlines()]))
elif type(res) == type(dict()):
for f... | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def on_any(self, *args, **kwargs):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def runner_on_ok(self, host, res):
human_log('runner_on_ok', host, res) | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def runner_on_skipped(self, host, item=None):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def runner_on_no_hosts(self):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def runner_on_async_ok(self, host, res, jid):
human_log('runner_on_async_ok', host, res) | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def playbook_on_start(self):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def playbook_on_no_hosts_matched(self):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def playbook_on_task_start(self, name, is_conditional):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def playbook_on_setup(self):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def playbook_on_not_import_for_host(self, host, missing_file):
pass | soarpenguin/python-scripts | [
63,
40,
63,
1,
1397484324
] |
def parse_datetime(s: str) -> datetime.datetime:
return iso8601.parse_date(s).replace(tzinfo=None) | sfu-fas/coursys | [
61,
17,
61,
39,
1407368110
] |
def add_arguments(self, parser):
parser.add_argument('offering_slug', type=str, help='CourseOffering slug')
parser.add_argument('activity_slug', type=str, help='the slug of the Activity with the quiz')
parser.add_argument('section', type=str, help='lab/tutorial section to modify')
parser... | sfu-fas/coursys | [
61,
17,
61,
39,
1407368110
] |
def GetName(self):
return "SFM10" | turdusmerula/kicad-plugins | [
3,
1,
3,
1,
1489351432
] |
def GetValue(self):
return "SFM10" | turdusmerula/kicad-plugins | [
3,
1,
3,
1,
1489351432
] |
def CheckParameters(self):
self.CheckParamInt(
"Pads", '*' + self.pad_num_pads_horz_key,
is_multiple_of=2) | turdusmerula/kicad-plugins | [
3,
1,
3,
1,
1489351432
] |
def GetPad(self, rot_degree=0):
pad_length = self.parameters["Pads"][self.pad_length_key]
pad_width = self.parameters["Pads"][self.pad_width_key]
pad_handsolder = self.parameters["Pads"][self.pad_handsolder_key] | turdusmerula/kicad-plugins | [
3,
1,
3,
1,
1489351432
] |
def BuildThisFootprint(self): | turdusmerula/kicad-plugins | [
3,
1,
3,
1,
1489351432
] |
def __init__(self, timeout=5, attempts=3):
self._timeout = timeout
self._attempts = attempts
self._transaction_id = b"" | xmikos/qopenvpn | [
36,
11,
36,
6,
1360971075
] |
def _generate_id(self):
"""Generate random Transaction ID"""
return os.urandom(16) | xmikos/qopenvpn | [
36,
11,
36,
6,
1360971075
] |
def _parse_response(self, data):
"""Parse server response to get mapped address"""
packet_type, length = struct.unpack(">2H", data[:4])
if packet_type != BINDING_RESPONSE:
raise ValueError("Invalid response type!")
if data[4:20] != self._transaction_id:
raise Valu... | xmikos/qopenvpn | [
36,
11,
36,
6,
1360971075
] |
def _parse_mapped_address(self, value):
"""Get IP address and port from MAPPED_ADDRESS attribute"""
family, recv_port = struct.unpack(">xBH", value[:4])
if family != FAMILY_IPV4:
raise ValueError("IPv6 is not supported!")
ip_address = socket.inet_ntoa(value[4:])
retur... | xmikos/qopenvpn | [
36,
11,
36,
6,
1360971075
] |
def __init__(self,waitTime):
self.waitTime = waitTime
threading.Thread.__init__(self) | surajshanbhag/Indoor_SLAM | [
11,
7,
11,
1,
1492211651
] |
def right():
global rightC
rightC += 1
print "right: ",rightC,"\t","left :",leftC | surajshanbhag/Indoor_SLAM | [
11,
7,
11,
1,
1492211651
] |
def checkArgs():
global IP,host
if(len(sys.argv)!=1):
IP = sys.argv[1]
host = sys.argv[2] | surajshanbhag/Indoor_SLAM | [
11,
7,
11,
1,
1492211651
] |
def render_aspect_ratio(aspect_ratio, use_default=False):
'''
Returns the aspect ratio if one is defined for the source, otherwise
if defaults are accepted a default value of 1.0 is returned or else
a ValueError is raised
:param float aspect_ratio:
Ratio of along strike-length to down-dip w... | gem/oq-hazardlib | [
23,
49,
23,
9,
1323944086
] |
def npd_to_pmf(nodal_plane_dist, use_default=False):
"""
Returns the nodal plane distribution as an instance of the PMF class
"""
if isinstance(nodal_plane_dist, PMF):
# Aready in PMF format - return
return nodal_plane_dist
else:
if use_default:
return PMF([(1.0, ... | gem/oq-hazardlib | [
23,
49,
23,
9,
1323944086
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.