function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def as_list(data, use_pandas=True, header=True):
"""
Convert an H2O data object into a python-specific object.
WARNING! This will pull all data local!
If Pandas is available (and use_pandas is True), then pandas will be used to parse the
data frame. Otherwise, a list-of-lists populated by characte... | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def load_dataset(relative_path):
"""Imports a data file within the 'h2o_data' folder."""
assert_is_type(relative_path, str)
h2o_dir = os.path.split(__file__)[0]
for possible_file in [os.path.join(h2o_dir, relative_path),
os.path.join(h2o_dir, "h2o_data", relative_path),
... | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def flow():
"""
Open H2O Flow in your browser.
"""
webbrowser.open(connection().base_url, new = 1) | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def _create_zip_file(dest_filename, *content_list):
from .utils.shared_utils import InMemoryZipArch
with InMemoryZipArch(dest_filename) as zip_arch:
for filename, file_content in content_list:
zip_arch.append(filename, file_content)
return dest_filename | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def upload_custom_metric(func, func_file="metrics.py", func_name=None, class_name=None, source_provider=None):
"""
Upload given metrics function into H2O cluster.
The metrics can have different representation:
- method
- class: needs to inherit from water.udf.CFunc2 and implement method apply(a... | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def _check_connection():
if not h2oconn or not h2oconn.cluster:
raise H2OConnectionError("Not connected to a cluster. Did you run `h2o.connect()`?") | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def import_frame():
"""Deprecated."""
import_file() | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def parse():
"""Deprecated."""
pass | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def cluster_info():
"""Deprecated."""
_check_connection()
cluster().show_status() | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def cluster_status():
"""Deprecated."""
_check_connection()
cluster().show_status(True) | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def shutdown(prompt=False):
"""Deprecated."""
_check_connection()
cluster().shutdown(prompt) | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def network_test():
"""Deprecated."""
_check_connection()
cluster().network_test() | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def get_timezone():
"""Deprecated."""
_check_connection()
return cluster().timezone | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def set_timezone(value):
"""Deprecated."""
_check_connection()
cluster().timezone = value | h2oai/h2o-dev | [
6169,
1943,
6169,
208,
1393862887
] |
def get_host_target(env):
debug('vc.py:get_host_target()')
host_platform = env.get('HOST_ARCH')
if not host_platform:
host_platform = platform.machine()
# TODO(2.5): the native Python platform.machine() function returns
# '' on all Python versions before 2.6, after which it also us... | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def msvc_version_to_maj_min(msvc_version):
msvc_version_numeric = ''.join([x for x in msvc_version if x in string_digits + '.'])
t = msvc_version_numeric.split(".")
if not len(t) == 2:
raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric))
try:
maj = int(t[0])... | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def find_vc_pdir(msvc_version):
"""Try to find the product directory for the given
version.
Note
----
If for some reason the requested version could not be found, an
exception which inherits from VisualCException will be raised."""
root = 'Software\\'
if common.is_win64():
root ... | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def cached_get_installed_vcs():
global __INSTALLED_VCS_RUN
if __INSTALLED_VCS_RUN is None:
ret = get_installed_vcs()
__INSTALLED_VCS_RUN = ret
return __INSTALLED_VCS_RUN | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def reset_installed_vcs():
"""Make it try again to find VC. This is just for the tests."""
__INSTALLED_VCS_RUN = None | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def script_env(script, args=None):
cache_key = (script, args)
stdout = script_env_stdout_cache.get(cache_key, None)
if stdout is None:
stdout = common.get_output(script, args)
script_env_stdout_cache[cache_key] = stdout
# Stupid batch files do not set return code: we take a look at the
... | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def msvc_setup_env_once(env):
try:
has_run = env["MSVC_SETUP_RUN"]
except KeyError:
has_run = False
if not has_run:
msvc_setup_env(env)
env["MSVC_SETUP_RUN"] = True | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def msvc_setup_env(env):
debug('msvc_setup_env()')
version = get_default_version(env)
if version is None:
warn_msg = "No version of Visual Studio compiler found - C/C++ " \
"compilers most likely not set correctly"
# Nuitka: Useless warning for us.
# SCons.Warning... | kayhayen/Nuitka | [
8411,
456,
8411,
240,
1366731633
] |
def _parse_args() -> argparse.Namespace:
"""Setup argparse and parse command line args."""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='command',
metavar='<command>',
required=True)
project_par... | google/pigweed | [
161,
44,
161,
1,
1615327645
] |
def format_raw(self, netenv, indent="", embedded=True,
indirect_attrs=True):
details = [indent + "{0:c}: {0.name}".format(netenv)]
details.append(self.redirect_raw(netenv.dns_environment, indent + " "))
if netenv.location:
details.append(self.redirect_raw(netenv.l... | quattor/aquilon | [
12,
16,
12,
38,
1361797498
] |
def setUp(self):
self.set_filename('page_breaks04.xlsx')
self.ignore_files = ['xl/printerSettings/printerSettings1.bin',
'xl/worksheets/_rels/sheet1.xml.rels']
self.ignore_elements = {'[Content_Types].xml': ['<Default Extension="bin"'],
... | jmcnamara/XlsxWriter | [
3172,
594,
3172,
18,
1357261626
] |
def _file_extension_default(self):
return '.html' | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _default_template_path_default(self):
return os.path.join("..", "templates", "html") | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _template_file_default(self):
return 'full' | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def default_config(self):
c = Config({
'NbConvertBase': {
'display_data_priority' : ['application/vnd.jupyter.widget-state+json',
'application/vnd.jupyter.widget-view+json',
'application/javascript'... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def default_filters(self):
for pair in super(HTMLExporter, self).default_filters():
yield pair
yield ('markdown2html', self.markdown2html) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def extract夢見る世界(item):
"""
Parser for '夢見る世界'
""" | fake-name/ReadableWebProxy | [
191,
16,
191,
3,
1437712243
] |
def _default_stream():
return open(cjkdata.get_resource('tables/zhuyin_pinyin_conv_table')) | larsyencken/cjktools | [
20,
6,
20,
2,
1369698266
] |
def parse_lines(istream):
istream = stream_codec(istream)
for line in istream:
if not line.startswith('#'):
yield line.rstrip().split() | larsyencken/cjktools | [
20,
6,
20,
2,
1369698266
] |
def pinyin_to_zhuyin_table(istream=None):
""" Returns a dictionary mapping zhuyin to pinyin. """
with _get_stream_context(istream) as istream:
table = {}
for zhuyin, pinyin in parse_lines(istream):
table[pinyin] = zhuyin
return table | larsyencken/cjktools | [
20,
6,
20,
2,
1369698266
] |
def pinyin_regex_pattern(istream=None):
""" Returns a pinyin regex pattern, with optional tone number. """
all_pinyin = get_all_pinyin(istream)
# Sort from longest to shortest, so as to make maximum matches whenever
# possible.
all_pinyin = sorted(all_pinyin, key=len, reverse=True)
# Build a g... | larsyencken/cjktools | [
20,
6,
20,
2,
1369698266
] |
def _LogDevicesOnFailure(msg):
try:
yield
except base_error.BaseError:
logging.exception(msg)
logging.error('Devices visible to adb:')
for entry in adb_wrapper.AdbWrapper.Devices(desired_state=None,
long_list=True):
logging.error(' %s: %s',
... | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def Asan(args):
env = os.environ.copy()
env['ADB'] = args.adb
try:
with _LogDevicesOnFailure('Failed to set up the device.'):
device = device_utils.DeviceUtils.HealthyDevices(
device_arg=args.device)[0]
disable_verity = device.build_version_sdk >= version_codes.MARSHMALLOW
if disa... | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def post_request_json(url, data, headers=None):
"""Send json data via POST request and return response
Args:
url(str): url to send request to
data(dict): data to be sent
headers(dict): request headers
Returns:
json_response(dict)
"""
resp = None
json_response = ... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def delete_request_json(url, headers=None, data=None):
"""Send a DELETE request to a remote API and return its response
Args:
url(str): url to send request to
headers(dict): eventual request HEADERS to use in request
data(dict): eventual request data to ba passed as a json object
Ret... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_resource(url, json=False):
"""Fetch a resource and return the resulting lines in a list or a json object
Send file_name to get more clean log messages
Args:
url(str)
json(bool): if result should be in json
Returns:
data
"""
data = None
if url.startswith("f... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_genes_to_hpo_to_disease():
"""Fetch the latest version of the map from genes to phenotypes
Returns:
res(list(str)): A list with the lines formatted this way:
#Format: entrez-gene-id<tab>entrez-gene-symbol<tab>HPO-Term-Name<tab>\
HPO-Term-ID<tab>Frequency-Raw<tab>Frequency-H... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_hpo_files(genes_to_phenotype=False, phenotype_to_genes=False, hpo_terms=False):
"""
Fetch the necessary HPO files from http://compbio.charite.de
Args:
genes_to_phenotype(bool): if file genes_to_phenotype.txt is required
phenotype_to_genes(bool): if file phenotype_to_genes.txt is r... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_ensembl_biomart(attributes, filters, build=None):
"""Fetch data from ensembl biomart
Args:
attributes(list): List of selected attributes
filters(dict): Select what filters to use
build(str): '37' or '38'
Returns:
client(EnsemblBiomartClient)
"""
build = bu... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_ensembl_transcripts(build=None, chromosomes=None):
"""Fetch the ensembl genes
Args:
build(str): ['37', '38']
chromosomes(iterable(str))
Returns:
result(iterable): Ensembl formated transcript lines
"""
chromosomes = chromosomes or CHROMOSOMES
LOG.info("Fetching... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def fetch_hgnc():
"""Fetch the hgnc genes file from
ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt
Returns:
hgnc_gene_lines(list(str))
"""
file_name = "hgnc_complete_set.txt"
url = "ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/{0}".format(file_name)... | Clinical-Genomics/scout | [
122,
41,
122,
149,
1412930641
] |
def test_create_reply_with_text_not_render(self):
text = "test"
reply = create_reply(text, render=False)
self.assertEqual("text", reply.type)
self.assertEqual(text, reply.content)
reply.render() | jxtech/wechatpy | [
3364,
745,
3364,
44,
1410527008
] |
def test_create_reply_with_message(self):
from wechatpy.messages import TextMessage
msg = TextMessage(
{
"FromUserName": "user1",
"ToUserName": "user2",
}
)
reply = create_reply("test", msg, render=False)
self.assertEqual(... | jxtech/wechatpy | [
3364,
745,
3364,
44,
1410527008
] |
def test_create_reply_with_articles(self):
articles = [
{
"title": "test 1",
"description": "test 1",
"image": "http://www.qq.com/1.png",
"url": "http://www.qq.com/1",
},
{
"title": "test 2",
... | jxtech/wechatpy | [
3364,
745,
3364,
44,
1410527008
] |
def __init__(
self, plotly_name="tickformatstops", parent_name="contour.colorbar", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_marooned_pirate_tran_m.iff"
result.attribute_template_id = 9
result.stfName("npc_name","trandoshan_base_male") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_commoner_naboo_human_female_07.iff"
result.attribute_template_id = 9
result.stfName("npc_name","human_base_female") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def test_global(self):
clear_user_default("key1")
set_global_default("key1", "value1")
self.assertEqual(get_global_default("key1"), "value1")
set_global_default("key1", "value2")
self.assertEqual(get_global_default("key1"), "value2")
add_global_default("key1", "value3")
self.assertEqual(get_global_defau... | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def test_global_if_not_user(self):
set_global_default("key4", "value4")
self.assertEqual(get_user_default("key4"), "value4") | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def test_clear_global(self):
set_global_default("key6", "value6")
self.assertEqual(get_user_default("key6"), "value6")
clear_default("key6", value="value6")
self.assertEqual(get_user_default("key6"), None) | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def __init__(self, targets=None, priority=None, source=None, batch=False,
**kwargs):
"""
Initialize D7 Networks Object
"""
super(NotifyD7Networks, self).__init__(**kwargs)
# The Priority of the message
if priority not in D7NETWORK_SMS_PRIORITIES:
... | SickGear/SickGear | [
574,
83,
574,
2,
1415773777
] |
def url(self, privacy=False, *args, **kwargs):
"""
Returns the URL built dynamically based on specified arguments.
"""
# Define any arguments set
args = {
'format': self.notify_format,
'overflow': self.overflow_mode,
'verify': 'yes' if self.ve... | SickGear/SickGear | [
574,
83,
574,
2,
1415773777
] |
def test_404():
with db_connection.env(login_active=False):
req = app.request('/invalidendpoint', method='GET')
assert req.status == "404 Not Found"
req = app.request('/invalidendpoint', method='POST')
assert req.status == "404 Not Found" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def test_exists_stats():
with db_connection.env(login_active=False):
req = app.request('/stats', 'GET')
assert req.status == "200 OK"
req = app.request('/stats', 'POST')
assert req.status == "405 Method Not Allowed" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def test_exists_links():
with db_connection.env(login_active=False):
req = app.request('/links', 'GET')
assert req.status == "200 OK"
req = app.request('/links', 'POST')
assert req.status == "405 Method Not Allowed" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def test_exists_portinfo():
with db_connection.env(login_active=False):
req = app.request('/portinfo', 'GET')
assert req.status == "200 OK"
req = app.request('/portinfo', 'POST')
assert req.status == "200 OK" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def test_exists_table():
with db_connection.env(login_active=False):
req = app.request('/table', 'GET')
assert req.status == "200 OK"
req = app.request('/table', 'POST')
assert req.status == "405 Method Not Allowed" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def test_exists_settings_page():
with db_connection.env(login_active=False):
req = app.request('/settings_page', 'GET')
assert req.status == "200 OK"
req = app.request('/settings_page', 'POST')
assert req.status == "405 Method Not Allowed" | riolet/SAM | [
175,
17,
175,
5,
1467750068
] |
def find_abf_policy(test, id):
policies = test.vapi.abf_policy_dump()
for p in policies:
if id == p.policy.policy_id:
return True
return False | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self,
test,
policy_id,
acl,
paths):
self._test = test
self.policy_id = policy_id
self.acl = acl
self.paths = paths
self.encoded_paths = []
for path in self.paths:
self.encoded_pat... | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def remove_vpp_config(self):
self._test.vapi.abf_policy_add_del(
0,
{'policy_id': self.policy_id,
'acl_index': self.acl.acl_index,
'n_paths': len(self.paths),
'paths': self.encoded_paths}) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def object_id(self):
return ("abf-policy-%d" % self.policy_id) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __init__(self,
test,
policy_id,
sw_if_index,
priority,
is_ipv6=0):
self._test = test
self.policy_id = policy_id
self.sw_if_index = sw_if_index
self.priority = priority
self.is_ipv6 = is_ipv6 | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def remove_vpp_config(self):
self._test.vapi.abf_itf_attach_add_del(
0,
{'policy_id': self.policy_id,
'sw_if_index': self.sw_if_index,
'priority': self.priority,
'is_ipv6': self.is_ipv6}) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def object_id(self):
return ("abf-attach-%d-%d" % (self.policy_id, self.sw_if_index)) | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def setUpClass(cls):
super(TestAbf, cls).setUpClass() | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def tearDownClass(cls):
super(TestAbf, cls).tearDownClass() | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def tearDown(self):
for i in self.pg_interfaces:
i.unconfig_ip4()
i.unconfig_ip6()
i.admin_down()
super(TestAbf, self).tearDown() | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def test_abf6(self):
""" IPv6 ACL Based Forwarding
"""
#
# Simple test for matching IPv6 packets
#
#
# Rule 1
#
rule_1 = AclRule(is_permit=1, proto=17, ports=1234,
src_prefix=IPv6Network("2001::2/128"),
... | FDio/vpp | [
923,
525,
923,
24,
1499444980
] |
def __getattr__(self, attr):
if attr == 'rand_name':
# NOTE(flwang): This is a proxy to generate a random name that
# includes a random number and a prefix 'tempest'
attr_obj = partial(lib_data_utils.rand_name,
prefix='tempest')
else:
... | cisco-openstack/tempest | [
2,
2,
2,
1,
1410968777
] |
def get_service_list():
service_list = {
'compute': CONF.service_available.nova,
'image': CONF.service_available.glance,
'volume': CONF.service_available.cinder,
# NOTE(masayukig): We have two network services which are neutron and
# nova-network. And we have no way to know w... | cisco-openstack/tempest | [
2,
2,
2,
1,
1410968777
] |
def decorator(f):
known_services = get_service_list()
for service in args:
if service not in known_services:
raise InvalidServiceTag('%s is not a valid service' % service)
decorators.attr(type=list(args))(f)
@functools.wraps(f)
def wrapper(*func_args... | cisco-openstack/tempest | [
2,
2,
2,
1,
1410968777
] |
def requires_ext(**kwargs):
"""A decorator to skip tests if an extension is not enabled
@param extension
@param service
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*func_args, **func_kwargs):
if not is_extension_enabled(kwargs['extension'],
... | cisco-openstack/tempest | [
2,
2,
2,
1,
1410968777
] |
def get_parser(self, prog_name):
parser = super(CreateUser, self).get_parser(prog_name)
parser.add_argument(
'name',
metavar='<name>',
help='New user name',
)
parser.add_argument(
'--domain',
metavar='<domain>',
help... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def get_parser(self, prog_name):
parser = super(DeleteUser, self).get_parser(prog_name)
parser.add_argument(
'users',
metavar='<user>',
nargs="+",
help='User(s) to delete (name or ID)',
)
parser.add_argument(
'--domain',
... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def get_parser(self, prog_name):
parser = super(ListUser, self).get_parser(prog_name)
parser.add_argument(
'--domain',
metavar='<domain>',
help='Filter users by <domain> (name or ID)',
)
project_or_group = parser.add_mutually_exclusive_group()
... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def get_parser(self, prog_name):
parser = super(SetUser, self).get_parser(prog_name)
parser.add_argument(
'user',
metavar='<user>',
help='User to change (name or ID)',
)
parser.add_argument(
'--name',
metavar='<name>',
... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def get_parser(self, prog_name):
parser = super(SetPasswordUser, self).get_parser(prog_name)
parser.add_argument(
'--password',
metavar='<new-password>',
help='New user password'
)
parser.add_argument(
'--original-password',
met... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def get_parser(self, prog_name):
parser = super(ShowUser, self).get_parser(prog_name)
parser.add_argument(
'user',
metavar='<user>',
help='User to display (name or ID)',
)
parser.add_argument(
'--domain',
metavar='<domain>',
... | nttcom/eclcli | [
22,
15,
22,
1,
1472615846
] |
def __init__(self,**params):
super(CameraImage,self).__init__(**params)
self._image = None | ioam/topographica | [
51,
31,
51,
228,
1348109103
] |
def _decode_image(self,fmt,w,h,bpp,fdiv,data):
if fmt==1:
self._image = Image.new('L',(w,h))
self._image.fromstring(data,'raw')
else:
# JPALERT: if not grayscale, then assume color. This
# should be expanded for other modes.
rgb_im = Image.new... | ioam/topographica | [
51,
31,
51,
228,
1348109103
] |
def _get_image(self,params):
im_spec = None
if self._image is None:
# if we don't have an image then block until we get one
im_spec = self.camera.image_queue.get()
self.camera.image_queue.task_done()
# Make sure we clear the image queue and get the most rec... | ioam/topographica | [
51,
31,
51,
228,
1348109103
] |
def start(self):
pass | ioam/topographica | [
51,
31,
51,
228,
1348109103
] |
def get_namespace_choices():
"""
Return the enum to the caller
"""
return NAMESPACE_CHOICES | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def add_prerequisite_course(course_key, prerequisite_course_key):
"""
It would create a milestone, then it would set newly created
milestones as requirement for course referred by `course_key`
and it would set newly created milestone as fulfillment
milestone for course referred by `prerequisite_cour... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def set_prerequisite_courses(course_key, prerequisite_course_keys):
"""
It would remove any existing requirement milestones for the given `course_key`
and create new milestones for each pre-requisite course in `prerequisite_course_keys`.
To only remove course milestones pass `course_key` and empty list ... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def get_prerequisite_courses_display(course_descriptor):
"""
It would retrieve pre-requisite courses, make display strings
and return list of dictionary with course key as 'key' field
and course display name as `display` field.
"""
pre_requisite_courses = []
if is_prerequisite_courses_enable... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def fulfill_course_milestone(course_key, user):
"""
Marks the course specified by the given course_key as complete for the given user.
If any other courses require this course as a prerequisite, their milestones will be appropriately updated.
"""
if not ENABLE_MILESTONES_APP.is_enabled():
re... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def get_required_content(course_key, user):
"""
Queries milestones subsystem to see if the specified course is gated on one or more milestones,
and if those milestones can be fulfilled via completion of a particular course content module
"""
required_content = []
if ENABLE_MILESTONES_APP.is_enab... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def is_valid_course_key(key):
"""
validates course key. returns True if valid else False.
"""
try:
course_key = CourseKey.from_string(key)
except InvalidKeyError:
course_key = key
return isinstance(course_key, CourseKey) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def generate_milestone_namespace(namespace, course_key=None):
"""
Returns a specifically-formatted namespace string for the specified type
"""
if namespace in list(NAMESPACE_CHOICES.values()):
if namespace == 'entrance_exams':
return '{}.{}'.format(str(course_key), NAMESPACE_CHOICES[... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def add_milestone(milestone_data):
"""
Client API operation adapter/wrapper
"""
if not ENABLE_MILESTONES_APP.is_enabled():
return None
return milestones_api.add_milestone(milestone_data) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def get_milestone_relationship_types():
"""
Client API operation adapter/wrapper
"""
if not ENABLE_MILESTONES_APP.is_enabled():
return {}
return milestones_api.get_milestone_relationship_types() | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def get_course_milestones(course_id):
"""
Client API operation adapter/wrapper
"""
if not ENABLE_MILESTONES_APP.is_enabled():
return []
return milestones_api.get_course_milestones(course_id) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def get_course_content_milestones(course_id, content_id=None, relationship='requires', user_id=None):
"""
Client API operation adapter/wrapper
Uses the request cache to store all of a user's
milestones
Returns all content blocks in a course if content_id is None, otherwise it just returns that
... | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
def remove_content_references(content_id):
"""
Client API operation adapter/wrapper
"""
if not ENABLE_MILESTONES_APP.is_enabled():
return None
return milestones_api.remove_content_references(content_id) | eduNEXT/edx-platform | [
5,
3,
5,
6,
1390926698
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.