partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Instrument.table | a ```pylsdj.Table``` referencing the instrument's table, or None
if the instrument doesn't have a table | pylsdj/instrument.py | def table(self):
"""a ```pylsdj.Table``` referencing the instrument's table, or None
if the instrument doesn't have a table"""
if hasattr(self.data, 'table_on') and self.data.table_on:
assert_index_sane(self.data.table, len(self.song.tables))
return self.song.tables[self.... | def table(self):
"""a ```pylsdj.Table``` referencing the instrument's table, or None
if the instrument doesn't have a table"""
if hasattr(self.data, 'table_on') and self.data.table_on:
assert_index_sane(self.data.table, len(self.song.tables))
return self.song.tables[self.... | [
"a",
"pylsdj",
".",
"Table",
"referencing",
"the",
"instrument",
"s",
"table",
"or",
"None",
"if",
"the",
"instrument",
"doesn",
"t",
"have",
"a",
"table"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L47-L52 | [
"def",
"table",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"data",
",",
"'table_on'",
")",
"and",
"self",
".",
"data",
".",
"table_on",
":",
"assert_index_sane",
"(",
"self",
".",
"data",
".",
"table",
",",
"len",
"(",
"self",
".",
"... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Instrument.import_lsdinst | import from an lsdinst struct | pylsdj/instrument.py | def import_lsdinst(self, struct_data):
"""import from an lsdinst struct"""
self.name = struct_data['name']
self.automate = struct_data['data']['automate']
self.pan = struct_data['data']['pan']
if self.table is not None:
self.table.import_lsdinst(struct_data) | def import_lsdinst(self, struct_data):
"""import from an lsdinst struct"""
self.name = struct_data['name']
self.automate = struct_data['data']['automate']
self.pan = struct_data['data']['pan']
if self.table is not None:
self.table.import_lsdinst(struct_data) | [
"import",
"from",
"an",
"lsdinst",
"struct"
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L79-L86 | [
"def",
"import_lsdinst",
"(",
"self",
",",
"struct_data",
")",
":",
"self",
".",
"name",
"=",
"struct_data",
"[",
"'name'",
"]",
"self",
".",
"automate",
"=",
"struct_data",
"[",
"'data'",
"]",
"[",
"'automate'",
"]",
"self",
".",
"pan",
"=",
"struct_dat... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | Instrument.export_to_file | Export this instrument's settings to a file.
:param filename: the name of the file | pylsdj/instrument.py | def export_to_file(self, filename):
"""Export this instrument's settings to a file.
:param filename: the name of the file
"""
instr_json = self.export_struct()
with open(filename, 'w') as fp:
json.dump(instr_json, fp, indent=2) | def export_to_file(self, filename):
"""Export this instrument's settings to a file.
:param filename: the name of the file
"""
instr_json = self.export_struct()
with open(filename, 'w') as fp:
json.dump(instr_json, fp, indent=2) | [
"Export",
"this",
"instrument",
"s",
"settings",
"to",
"a",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L88-L96 | [
"def",
"export_to_file",
"(",
"self",
",",
"filename",
")",
":",
"instr_json",
"=",
"self",
".",
"export_struct",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fp",
":",
"json",
".",
"dump",
"(",
"instr_json",
",",
"fp",
",",
"in... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | KitSample.write_wav | Write this sample to a WAV file.
:param filename: the file to which to write | pylsdj/kits.py | def write_wav(self, filename):
"""Write this sample to a WAV file.
:param filename: the file to which to write
"""
wave_output = None
try:
wave_output = wave.open(filename, 'w')
wave_output.setparams(WAVE_PARAMS)
frames = bytearray([x << 4 ... | def write_wav(self, filename):
"""Write this sample to a WAV file.
:param filename: the file to which to write
"""
wave_output = None
try:
wave_output = wave.open(filename, 'w')
wave_output.setparams(WAVE_PARAMS)
frames = bytearray([x << 4 ... | [
"Write",
"this",
"sample",
"to",
"a",
"WAV",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L229-L246 | [
"def",
"write_wav",
"(",
"self",
",",
"filename",
")",
":",
"wave_output",
"=",
"None",
"try",
":",
"wave_output",
"=",
"wave",
".",
"open",
"(",
"filename",
",",
"'w'",
")",
"wave_output",
".",
"setparams",
"(",
"WAVE_PARAMS",
")",
"frames",
"=",
"bytea... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | KitSample.read_wav | Read sample data for this sample from a WAV file.
:param filename: the file from which to read | pylsdj/kits.py | def read_wav(self, filename):
"""Read sample data for this sample from a WAV file.
:param filename: the file from which to read
"""
wave_input = None
try:
wave_input = wave.open(filename, 'r')
wave_frames = bytearray(
wave_input.readframe... | def read_wav(self, filename):
"""Read sample data for this sample from a WAV file.
:param filename: the file from which to read
"""
wave_input = None
try:
wave_input = wave.open(filename, 'r')
wave_frames = bytearray(
wave_input.readframe... | [
"Read",
"sample",
"data",
"for",
"this",
"sample",
"from",
"a",
"WAV",
"file",
"."
] | alexras/pylsdj | python | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L248-L264 | [
"def",
"read_wav",
"(",
"self",
",",
"filename",
")",
":",
"wave_input",
"=",
"None",
"try",
":",
"wave_input",
"=",
"wave",
".",
"open",
"(",
"filename",
",",
"'r'",
")",
"wave_frames",
"=",
"bytearray",
"(",
"wave_input",
".",
"readframes",
"(",
"wave_... | 1c45a7919dd324e941f76b315558b9647892e4d5 |
train | get_device_address | find the local ip address on the given device | headsup.py | def get_device_address(device):
""" find the local ip address on the given device """
if device is None:
return None
command = ['ip', 'route', 'list', 'dev', device]
ip_routes = subprocess.check_output(command).strip()
for line in ip_routes.split('\n'):
seen = ''
for a in lin... | def get_device_address(device):
""" find the local ip address on the given device """
if device is None:
return None
command = ['ip', 'route', 'list', 'dev', device]
ip_routes = subprocess.check_output(command).strip()
for line in ip_routes.split('\n'):
seen = ''
for a in lin... | [
"find",
"the",
"local",
"ip",
"address",
"on",
"the",
"given",
"device"
] | thusoy/headsup | python | https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L68-L80 | [
"def",
"get_device_address",
"(",
"device",
")",
":",
"if",
"device",
"is",
"None",
":",
"return",
"None",
"command",
"=",
"[",
"'ip'",
",",
"'route'",
",",
"'list'",
",",
"'dev'",
",",
"device",
"]",
"ip_routes",
"=",
"subprocess",
".",
"check_output",
... | 165a63cc6c987f664f2efd901d483ca07b7bc898 |
train | get_default_net_device | Find the device where the default route is. | headsup.py | def get_default_net_device():
""" Find the device where the default route is. """
with open('/proc/net/route') as fh:
for line in fh:
iface, dest, _ = line.split(None, 2)
if dest == '00000000':
return iface
return None | def get_default_net_device():
""" Find the device where the default route is. """
with open('/proc/net/route') as fh:
for line in fh:
iface, dest, _ = line.split(None, 2)
if dest == '00000000':
return iface
return None | [
"Find",
"the",
"device",
"where",
"the",
"default",
"route",
"is",
"."
] | thusoy/headsup | python | https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L83-L90 | [
"def",
"get_default_net_device",
"(",
")",
":",
"with",
"open",
"(",
"'/proc/net/route'",
")",
"as",
"fh",
":",
"for",
"line",
"in",
"fh",
":",
"iface",
",",
"dest",
",",
"_",
"=",
"line",
".",
"split",
"(",
"None",
",",
"2",
")",
"if",
"dest",
"==... | 165a63cc6c987f664f2efd901d483ca07b7bc898 |
train | add_missing_optional_args_with_value_none | Adds key-value pairs to the passed dictionary, so that
afterwards, the dictionary can be used without needing
to check for KeyErrors.
If the keys passed as a second argument are not present,
they are added with None as a value.
:args: The dictionary to be completed.
:optional_args:... | b2handle/util/argsutils.py | def add_missing_optional_args_with_value_none(args, optional_args):
'''
Adds key-value pairs to the passed dictionary, so that
afterwards, the dictionary can be used without needing
to check for KeyErrors.
If the keys passed as a second argument are not present,
they are added with ... | def add_missing_optional_args_with_value_none(args, optional_args):
'''
Adds key-value pairs to the passed dictionary, so that
afterwards, the dictionary can be used without needing
to check for KeyErrors.
If the keys passed as a second argument are not present,
they are added with ... | [
"Adds",
"key",
"-",
"value",
"pairs",
"to",
"the",
"passed",
"dictionary",
"so",
"that",
"afterwards",
"the",
"dictionary",
"can",
"be",
"used",
"without",
"needing",
"to",
"check",
"for",
"KeyErrors",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L3-L21 | [
"def",
"add_missing_optional_args_with_value_none",
"(",
"args",
",",
"optional_args",
")",
":",
"for",
"name",
"in",
"optional_args",
":",
"if",
"not",
"name",
"in",
"args",
".",
"keys",
"(",
")",
":",
"args",
"[",
"name",
"]",
"=",
"None",
"return",
"arg... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | check_presence_of_mandatory_args | Checks whether all mandatory arguments are passed.
This function aims at methods with many arguments
which are passed as kwargs so that the order
in which the are passed does not matter.
:args: The dictionary passed as args.
:mandatory_args: A list of keys that have to be
present i... | b2handle/util/argsutils.py | def check_presence_of_mandatory_args(args, mandatory_args):
'''
Checks whether all mandatory arguments are passed.
This function aims at methods with many arguments
which are passed as kwargs so that the order
in which the are passed does not matter.
:args: The dictionary passed as arg... | def check_presence_of_mandatory_args(args, mandatory_args):
'''
Checks whether all mandatory arguments are passed.
This function aims at methods with many arguments
which are passed as kwargs so that the order
in which the are passed does not matter.
:args: The dictionary passed as arg... | [
"Checks",
"whether",
"all",
"mandatory",
"arguments",
"are",
"passed",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L24-L47 | [
"def",
"check_presence_of_mandatory_args",
"(",
"args",
",",
"mandatory_args",
")",
":",
"missing_args",
"=",
"[",
"]",
"for",
"name",
"in",
"mandatory_args",
":",
"if",
"name",
"not",
"in",
"args",
".",
"keys",
"(",
")",
":",
"missing_args",
".",
"append",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | PyZip.size | Retrieves the size in bytes of this ZIP content.
:return: Size of the zip content in bytes | pyzip/__init__.py | def size(self, store_hashes=True):
"""
Retrieves the size in bytes of this ZIP content.
:return: Size of the zip content in bytes
"""
if self.modified:
self.__cache_content(store_hashes)
return len(self.cached_content) | def size(self, store_hashes=True):
"""
Retrieves the size in bytes of this ZIP content.
:return: Size of the zip content in bytes
"""
if self.modified:
self.__cache_content(store_hashes)
return len(self.cached_content) | [
"Retrieves",
"the",
"size",
"in",
"bytes",
"of",
"this",
"ZIP",
"content",
".",
":",
"return",
":",
"Size",
"of",
"the",
"zip",
"content",
"in",
"bytes"
] | ipazc/pyzip | python | https://github.com/ipazc/pyzip/blob/8680775ddba079a9a04ef3904252a9afb62cb7cc/pyzip/__init__.py#L171-L179 | [
"def",
"size",
"(",
"self",
",",
"store_hashes",
"=",
"True",
")",
":",
"if",
"self",
".",
"modified",
":",
"self",
".",
"__cache_content",
"(",
"store_hashes",
")",
"return",
"len",
"(",
"self",
".",
"cached_content",
")"
] | 8680775ddba079a9a04ef3904252a9afb62cb7cc |
train | Command.monkey_patch_migration_template | Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE
Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we
don't have to do any complex regex or reflection.
It's hacky... but works atm. | django_migration_fixture/management/commands/create_initial_data_fixtures.py | def monkey_patch_migration_template(self, app, fixture_path):
"""
Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE
Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we
don't have to do any complex regex or reflection.
It's hacky... but wo... | def monkey_patch_migration_template(self, app, fixture_path):
"""
Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE
Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we
don't have to do any complex regex or reflection.
It's hacky... but wo... | [
"Monkey",
"patch",
"the",
"django",
".",
"db",
".",
"migrations",
".",
"writer",
".",
"MIGRATION_TEMPLATE"
] | alexhayes/django-migration-fixture | python | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L38-L69 | [
"def",
"monkey_patch_migration_template",
"(",
"self",
",",
"app",
",",
"fixture_path",
")",
":",
"self",
".",
"_MIGRATION_TEMPLATE",
"=",
"writer",
".",
"MIGRATION_TEMPLATE",
"module_split",
"=",
"app",
".",
"module",
".",
"__name__",
".",
"split",
"(",
"'.'",
... | c0463edc599d96bc6f645084eb50e6e94e1f681a |
train | Command.migration_exists | Return true if it looks like a migration already exists. | django_migration_fixture/management/commands/create_initial_data_fixtures.py | def migration_exists(self, app, fixture_path):
"""
Return true if it looks like a migration already exists.
"""
base_name = os.path.basename(fixture_path)
# Loop through all migrations
for migration_path in glob.glob(os.path.join(app.path, 'migrations', '*.py')):
... | def migration_exists(self, app, fixture_path):
"""
Return true if it looks like a migration already exists.
"""
base_name = os.path.basename(fixture_path)
# Loop through all migrations
for migration_path in glob.glob(os.path.join(app.path, 'migrations', '*.py')):
... | [
"Return",
"true",
"if",
"it",
"looks",
"like",
"a",
"migration",
"already",
"exists",
"."
] | alexhayes/django-migration-fixture | python | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L77-L86 | [
"def",
"migration_exists",
"(",
"self",
",",
"app",
",",
"fixture_path",
")",
":",
"base_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fixture_path",
")",
"# Loop through all migrations",
"for",
"migration_path",
"in",
"glob",
".",
"glob",
"(",
"os",
... | c0463edc599d96bc6f645084eb50e6e94e1f681a |
train | Command.create_migration | Create a data migration for app that uses fixture_path. | django_migration_fixture/management/commands/create_initial_data_fixtures.py | def create_migration(self, app, fixture_path):
"""
Create a data migration for app that uses fixture_path.
"""
self.monkey_patch_migration_template(app, fixture_path)
out = StringIO()
management.call_command('makemigrations', app.label, empty=True, stdout=out)
s... | def create_migration(self, app, fixture_path):
"""
Create a data migration for app that uses fixture_path.
"""
self.monkey_patch_migration_template(app, fixture_path)
out = StringIO()
management.call_command('makemigrations', app.label, empty=True, stdout=out)
s... | [
"Create",
"a",
"data",
"migration",
"for",
"app",
"that",
"uses",
"fixture_path",
"."
] | alexhayes/django-migration-fixture | python | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L88-L99 | [
"def",
"create_migration",
"(",
"self",
",",
"app",
",",
"fixture_path",
")",
":",
"self",
".",
"monkey_patch_migration_template",
"(",
"app",
",",
"fixture_path",
")",
"out",
"=",
"StringIO",
"(",
")",
"management",
".",
"call_command",
"(",
"'makemigrations'",... | c0463edc599d96bc6f645084eb50e6e94e1f681a |
train | EUDATHandleClient.instantiate_for_read_and_search | Initialize client with read access and with search function.
:param handle_server_url: The URL of the Handle Server. May be None
(then, the default 'https://hdl.handle.net' is used).
:param reverselookup_username: The username to authenticate at the
reverse lookup servlet.
... | b2handle/handleclient.py | def instantiate_for_read_and_search(handle_server_url, reverselookup_username, reverselookup_password, **config):
'''
Initialize client with read access and with search function.
:param handle_server_url: The URL of the Handle Server. May be None
(then, the default 'https://hdl.hand... | def instantiate_for_read_and_search(handle_server_url, reverselookup_username, reverselookup_password, **config):
'''
Initialize client with read access and with search function.
:param handle_server_url: The URL of the Handle Server. May be None
(then, the default 'https://hdl.hand... | [
"Initialize",
"client",
"with",
"read",
"access",
"and",
"with",
"search",
"function",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L183-L209 | [
"def",
"instantiate_for_read_and_search",
"(",
"handle_server_url",
",",
"reverselookup_username",
",",
"reverselookup_password",
",",
"*",
"*",
"config",
")",
":",
"if",
"handle_server_url",
"is",
"None",
"and",
"'reverselookup_baseuri'",
"not",
"in",
"config",
".",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.instantiate_with_username_and_password | Initialize client against an HSv8 instance with full read/write access.
The method will throw an exception upon bad syntax or non-existing
Handle. The existence or validity of the password in the handle is
not checked at this moment.
:param handle_server_url: The URL of the Handle Syst... | b2handle/handleclient.py | def instantiate_with_username_and_password(handle_server_url, username, password, **config):
'''
Initialize client against an HSv8 instance with full read/write access.
The method will throw an exception upon bad syntax or non-existing
Handle. The existence or validity of the password i... | def instantiate_with_username_and_password(handle_server_url, username, password, **config):
'''
Initialize client against an HSv8 instance with full read/write access.
The method will throw an exception upon bad syntax or non-existing
Handle. The existence or validity of the password i... | [
"Initialize",
"client",
"against",
"an",
"HSv8",
"instance",
"with",
"full",
"read",
"/",
"write",
"access",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L212-L233 | [
"def",
"instantiate_with_username_and_password",
"(",
"handle_server_url",
",",
"username",
",",
"password",
",",
"*",
"*",
"config",
")",
":",
"inst",
"=",
"EUDATHandleClient",
"(",
"handle_server_url",
",",
"username",
"=",
"username",
",",
"password",
"=",
"pas... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.instantiate_with_credentials | Initialize the client against an HSv8 instance with full read/write
access.
:param credentials: A credentials object, see separate class
PIDClientCredentials.
:param \**config: More key-value pairs may be passed that will be passed
on to the constructor as config. Config... | b2handle/handleclient.py | def instantiate_with_credentials(credentials, **config):
'''
Initialize the client against an HSv8 instance with full read/write
access.
:param credentials: A credentials object, see separate class
PIDClientCredentials.
:param \**config: More key-value pairs may be p... | def instantiate_with_credentials(credentials, **config):
'''
Initialize the client against an HSv8 instance with full read/write
access.
:param credentials: A credentials object, see separate class
PIDClientCredentials.
:param \**config: More key-value pairs may be p... | [
"Initialize",
"the",
"client",
"against",
"an",
"HSv8",
"instance",
"with",
"full",
"read",
"/",
"write",
"access",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L236-L255 | [
"def",
"instantiate_with_credentials",
"(",
"credentials",
",",
"*",
"*",
"config",
")",
":",
"key_value_pairs",
"=",
"credentials",
".",
"get_all_args",
"(",
")",
"if",
"config",
"is",
"not",
"None",
":",
"key_value_pairs",
".",
"update",
"(",
"*",
"*",
"co... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.retrieve_handle_record_json | Retrieve a handle record from the Handle server as a complete nested
dict (including index, ttl, timestamp, ...) for later use.
Note: For retrieving a simple dict with only the keys and values,
please use :meth:`~b2handle.handleclient.EUDATHandleClient.retrieve_handle_record`.
:param h... | b2handle/handleclient.py | def retrieve_handle_record_json(self, handle):
'''
Retrieve a handle record from the Handle server as a complete nested
dict (including index, ttl, timestamp, ...) for later use.
Note: For retrieving a simple dict with only the keys and values,
please use :meth:`~b2handle.handle... | def retrieve_handle_record_json(self, handle):
'''
Retrieve a handle record from the Handle server as a complete nested
dict (including index, ttl, timestamp, ...) for later use.
Note: For retrieving a simple dict with only the keys and values,
please use :meth:`~b2handle.handle... | [
"Retrieve",
"a",
"handle",
"record",
"from",
"the",
"Handle",
"server",
"as",
"a",
"complete",
"nested",
"dict",
"(",
"including",
"index",
"ttl",
"timestamp",
"...",
")",
"for",
"later",
"use",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L259-L299 | [
"def",
"retrieve_handle_record_json",
"(",
"self",
",",
"handle",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'retrieve_handle_record_json...'",
")",
"utilhandle",
".",
"check_handle_syntax",
"(",
"handle",
")",
"response",
"=",
"self",
".",
"__send_handle_get_request",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.retrieve_handle_record | Retrieve a handle record from the Handle server as a dict. If there
is several entries of the same type, only the first one is
returned. Values of complex types (such as HS_ADMIN) are
transformed to strings.
:param handle: The handle whose record to retrieve.
:param handlerecord... | b2handle/handleclient.py | def retrieve_handle_record(self, handle, handlerecord_json=None):
'''
Retrieve a handle record from the Handle server as a dict. If there
is several entries of the same type, only the first one is
returned. Values of complex types (such as HS_ADMIN) are
transformed to strings.
... | def retrieve_handle_record(self, handle, handlerecord_json=None):
'''
Retrieve a handle record from the Handle server as a dict. If there
is several entries of the same type, only the first one is
returned. Values of complex types (such as HS_ADMIN) are
transformed to strings.
... | [
"Retrieve",
"a",
"handle",
"record",
"from",
"the",
"Handle",
"server",
"as",
"a",
"dict",
".",
"If",
"there",
"is",
"several",
"entries",
"of",
"the",
"same",
"type",
"only",
"the",
"first",
"one",
"is",
"returned",
".",
"Values",
"of",
"complex",
"type... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L302-L329 | [
"def",
"retrieve_handle_record",
"(",
"self",
",",
"handle",
",",
"handlerecord_json",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'retrieve_handle_record...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
"handle",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.get_value_from_handle | Retrieve a single value from a single Handle. If several entries with
this key exist, the methods returns the first one. If the handle
does not exist, the method will raise a HandleNotFoundException.
:param handle: The handle to take the value from.
:param key: The key.
:return:... | b2handle/handleclient.py | def get_value_from_handle(self, handle, key, handlerecord_json=None):
'''
Retrieve a single value from a single Handle. If several entries with
this key exist, the methods returns the first one. If the handle
does not exist, the method will raise a HandleNotFoundException.
:para... | def get_value_from_handle(self, handle, key, handlerecord_json=None):
'''
Retrieve a single value from a single Handle. If several entries with
this key exist, the methods returns the first one. If the handle
does not exist, the method will raise a HandleNotFoundException.
:para... | [
"Retrieve",
"a",
"single",
"value",
"from",
"a",
"single",
"Handle",
".",
"If",
"several",
"entries",
"with",
"this",
"key",
"exist",
"the",
"methods",
"returns",
"the",
"first",
"one",
".",
"If",
"the",
"handle",
"does",
"not",
"exist",
"the",
"method",
... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L331-L363 | [
"def",
"get_value_from_handle",
"(",
"self",
",",
"handle",
",",
"key",
",",
"handlerecord_json",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'get_value_from_handle...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.is_10320LOC_empty | Checks if there is a 10320/LOC entry in the handle record.
*Note:* In the unlikely case that there is a 10320/LOC entry, but it does
not contain any locations, it is treated as if there was none.
:param handle: The handle.
:param handlerecord_json: Optional. The content of the response ... | b2handle/handleclient.py | def is_10320LOC_empty(self, handle, handlerecord_json=None):
'''
Checks if there is a 10320/LOC entry in the handle record.
*Note:* In the unlikely case that there is a 10320/LOC entry, but it does
not contain any locations, it is treated as if there was none.
:param handle: The... | def is_10320LOC_empty(self, handle, handlerecord_json=None):
'''
Checks if there is a 10320/LOC entry in the handle record.
*Note:* In the unlikely case that there is a 10320/LOC entry, but it does
not contain any locations, it is treated as if there was none.
:param handle: The... | [
"Checks",
"if",
"there",
"is",
"a",
"10320",
"/",
"LOC",
"entry",
"in",
"the",
"handle",
"record",
".",
"*",
"Note",
":",
"*",
"In",
"the",
"unlikely",
"case",
"that",
"there",
"is",
"a",
"10320",
"/",
"LOC",
"entry",
"but",
"it",
"does",
"not",
"c... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L365-L402 | [
"def",
"is_10320LOC_empty",
"(",
"self",
",",
"handle",
",",
"handlerecord_json",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'is_10320LOC_empty...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
"handle",
",",
"han... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.generate_and_register_handle | Register a new Handle with a unique random name (random UUID).
:param prefix: The prefix of the handle to be registered. The method
will generate a suffix.
:param location: The URL of the data entity to be referenced.
:param checksum: Optional. The checksum string.
:param ex... | b2handle/handleclient.py | def generate_and_register_handle(self, prefix, location, checksum=None, additional_URLs=None, **extratypes):
'''
Register a new Handle with a unique random name (random UUID).
:param prefix: The prefix of the handle to be registered. The method
will generate a suffix.
:param... | def generate_and_register_handle(self, prefix, location, checksum=None, additional_URLs=None, **extratypes):
'''
Register a new Handle with a unique random name (random UUID).
:param prefix: The prefix of the handle to be registered. The method
will generate a suffix.
:param... | [
"Register",
"a",
"new",
"Handle",
"with",
"a",
"unique",
"random",
"name",
"(",
"random",
"UUID",
")",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L445-L471 | [
"def",
"generate_and_register_handle",
"(",
"self",
",",
"prefix",
",",
"location",
",",
"checksum",
"=",
"None",
",",
"additional_URLs",
"=",
"None",
",",
"*",
"*",
"extratypes",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'generate_and_register_handle...'",
")",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.modify_handle_value | Modify entries (key-value-pairs) in a handle record. If the key
does not exist yet, it is created.
*Note:* We assume that a key exists only once. In case a key exists
several time, an exception will be raised.
*Note:* To modify 10320/LOC, please use :meth:`~b2handle.handleclient.EUDATH... | b2handle/handleclient.py | def modify_handle_value(self, handle, ttl=None, add_if_not_exist=True, **kvpairs):
'''
Modify entries (key-value-pairs) in a handle record. If the key
does not exist yet, it is created.
*Note:* We assume that a key exists only once. In case a key exists
several time, an exceptio... | def modify_handle_value(self, handle, ttl=None, add_if_not_exist=True, **kvpairs):
'''
Modify entries (key-value-pairs) in a handle record. If the key
does not exist yet, it is created.
*Note:* We assume that a key exists only once. In case a key exists
several time, an exceptio... | [
"Modify",
"entries",
"(",
"key",
"-",
"value",
"-",
"pairs",
")",
"in",
"a",
"handle",
"record",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"yet",
"it",
"is",
"created",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L473-L587 | [
"def",
"modify_handle_value",
"(",
"self",
",",
"handle",
",",
"ttl",
"=",
"None",
",",
"add_if_not_exist",
"=",
"True",
",",
"*",
"*",
"kvpairs",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'modify_handle_value...'",
")",
"# Read handle record:",
"handlerecord_json... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.delete_handle_value | Delete a key-value pair from a handle record. If the key exists more
than once, all key-value pairs with this key are deleted.
:param handle: Handle from whose record the entry should be deleted.
:param key: Key to be deleted. Also accepts a list of keys.
:raises: :exc:`~b2handle.handle... | b2handle/handleclient.py | def delete_handle_value(self, handle, key):
'''
Delete a key-value pair from a handle record. If the key exists more
than once, all key-value pairs with this key are deleted.
:param handle: Handle from whose record the entry should be deleted.
:param key: Key to be deleted. Also... | def delete_handle_value(self, handle, key):
'''
Delete a key-value pair from a handle record. If the key exists more
than once, all key-value pairs with this key are deleted.
:param handle: Handle from whose record the entry should be deleted.
:param key: Key to be deleted. Also... | [
"Delete",
"a",
"key",
"-",
"value",
"pair",
"from",
"a",
"handle",
"record",
".",
"If",
"the",
"key",
"exists",
"more",
"than",
"once",
"all",
"key",
"-",
"value",
"pairs",
"with",
"this",
"key",
"are",
"deleted",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L589-L648 | [
"def",
"delete_handle_value",
"(",
"self",
",",
"handle",
",",
"key",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'delete_handle_value...'",
")",
"# read handle record:",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.delete_handle | Delete the handle and its handle record. If the Handle is not found, an Exception is raised.
:param handle: Handle to be deleted.
:param other: Deprecated. This only exists to catch wrong method usage
by users who are used to delete handle VALUES with the method.
:raises: :exc:`~b2h... | b2handle/handleclient.py | def delete_handle(self, handle, *other):
'''Delete the handle and its handle record. If the Handle is not found, an Exception is raised.
:param handle: Handle to be deleted.
:param other: Deprecated. This only exists to catch wrong method usage
by users who are used to delete handle... | def delete_handle(self, handle, *other):
'''Delete the handle and its handle record. If the Handle is not found, an Exception is raised.
:param handle: Handle to be deleted.
:param other: Deprecated. This only exists to catch wrong method usage
by users who are used to delete handle... | [
"Delete",
"the",
"handle",
"and",
"its",
"handle",
"record",
".",
"If",
"the",
"Handle",
"is",
"not",
"found",
"an",
"Exception",
"is",
"raised",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L650-L684 | [
"def",
"delete_handle",
"(",
"self",
",",
"handle",
",",
"*",
"other",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'delete_handle...'",
")",
"utilhandle",
".",
"check_handle_syntax",
"(",
"handle",
")",
"# Safety check. In old epic client, the method could be used for",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.exchange_additional_URL | Exchange an URL in the 10320/LOC entry against another, keeping the same id
and other attributes.
:param handle: The handle to modify.
:param old: The URL to replace.
:param new: The URL to set as new URL. | b2handle/handleclient.py | def exchange_additional_URL(self, handle, old, new):
'''
Exchange an URL in the 10320/LOC entry against another, keeping the same id
and other attributes.
:param handle: The handle to modify.
:param old: The URL to replace.
:param new: The URL to set as new URL.
... | def exchange_additional_URL(self, handle, old, new):
'''
Exchange an URL in the 10320/LOC entry against another, keeping the same id
and other attributes.
:param handle: The handle to modify.
:param old: The URL to replace.
:param new: The URL to set as new URL.
... | [
"Exchange",
"an",
"URL",
"in",
"the",
"10320",
"/",
"LOC",
"entry",
"against",
"another",
"keeping",
"the",
"same",
"id",
"and",
"other",
"attributes",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L686-L729 | [
"def",
"exchange_additional_URL",
"(",
"self",
",",
"handle",
",",
"old",
",",
"new",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'exchange_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"han... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.add_additional_URL | Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC
does not exist yet, it is created. If the 10320/LOC entry already
contains the URL, it is not added a second time.
:param handle: The handle to add the URL to.
:param urls: The URL(s) to be added. Several URLs may be s... | b2handle/handleclient.py | def add_additional_URL(self, handle, *urls, **attributes):
'''
Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC
does not exist yet, it is created. If the 10320/LOC entry already
contains the URL, it is not added a second time.
:param handle: The handle to add... | def add_additional_URL(self, handle, *urls, **attributes):
'''
Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC
does not exist yet, it is created. If the 10320/LOC entry already
contains the URL, it is not added a second time.
:param handle: The handle to add... | [
"Add",
"a",
"URL",
"entry",
"to",
"the",
"handle",
"record",
"s",
"10320",
"/",
"LOC",
"entry",
".",
"If",
"10320",
"/",
"LOC",
"does",
"not",
"exist",
"yet",
"it",
"is",
"created",
".",
"If",
"the",
"10320",
"/",
"LOC",
"entry",
"already",
"contains... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L731-L781 | [
"def",
"add_additional_URL",
"(",
"self",
",",
"handle",
",",
"*",
"urls",
",",
"*",
"*",
"attributes",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'add_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.remove_additional_URL | Remove a URL from the handle record's 10320/LOC entry.
:param handle: The handle to modify.
:param urls: The URL(s) to be removed. Several URLs may be specified.
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException`
:raises: :exc:`~b2handle.handleexceptions.HandleSyntaxErro... | b2handle/handleclient.py | def remove_additional_URL(self, handle, *urls):
'''
Remove a URL from the handle record's 10320/LOC entry.
:param handle: The handle to modify.
:param urls: The URL(s) to be removed. Several URLs may be specified.
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException... | def remove_additional_URL(self, handle, *urls):
'''
Remove a URL from the handle record's 10320/LOC entry.
:param handle: The handle to modify.
:param urls: The URL(s) to be removed. Several URLs may be specified.
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException... | [
"Remove",
"a",
"URL",
"from",
"the",
"handle",
"record",
"s",
"10320",
"/",
"LOC",
"entry",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L783-L825 | [
"def",
"remove_additional_URL",
"(",
"self",
",",
"handle",
",",
"*",
"urls",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'remove_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"handlerecord_js... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.register_handle | Registers a new Handle with given name. If the handle already exists
and overwrite is not set to True, the method will throw an
exception.
:param handle: The full name of the handle to be registered (prefix
and suffix)
:param location: The URL of the data entity to be refere... | b2handle/handleclient.py | def register_handle(self, handle, location, checksum=None, additional_URLs=None, overwrite=False, **extratypes):
'''
Registers a new Handle with given name. If the handle already exists
and overwrite is not set to True, the method will throw an
exception.
:param handle: The full... | def register_handle(self, handle, location, checksum=None, additional_URLs=None, overwrite=False, **extratypes):
'''
Registers a new Handle with given name. If the handle already exists
and overwrite is not set to True, the method will throw an
exception.
:param handle: The full... | [
"Registers",
"a",
"new",
"Handle",
"with",
"given",
"name",
".",
"If",
"the",
"handle",
"already",
"exists",
"and",
"overwrite",
"is",
"not",
"set",
"to",
"True",
"the",
"method",
"will",
"throw",
"an",
"exception",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L827-L930 | [
"def",
"register_handle",
"(",
"self",
",",
"handle",
",",
"location",
",",
"checksum",
"=",
"None",
",",
"additional_URLs",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"*",
"*",
"extratypes",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'register_handle.... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.search_handle | Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`.
... | b2handle/handleclient.py | def search_handle(self, URL=None, prefix=None, **key_value_pairs):
'''
Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, th... | def search_handle(self, URL=None, prefix=None, **key_value_pairs):
'''
Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, th... | [
"Search",
"for",
"handles",
"containing",
"the",
"specified",
"key",
"with",
"the",
"specified",
"value",
".",
"The",
"search",
"terms",
"are",
"passed",
"on",
"to",
"the",
"reverse",
"lookup",
"servlet",
"as",
"-",
"is",
".",
"The",
"servlet",
"is",
"supp... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L934-L973 | [
"def",
"search_handle",
"(",
"self",
",",
"URL",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"*",
"*",
"key_value_pairs",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'search_handle...'",
")",
"list_of_handles",
"=",
"self",
".",
"__searcher",
".",
"search_ha... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.generate_PID_name | Generate a unique random Handle name (random UUID). The Handle is not
registered. If a prefix is specified, the PID name has the syntax
<prefix>/<generatedname>, otherwise it just returns the generated
random name (suffix for the Handle).
:param prefix: Optional. The prefix to be used f... | b2handle/handleclient.py | def generate_PID_name(self, prefix=None):
'''
Generate a unique random Handle name (random UUID). The Handle is not
registered. If a prefix is specified, the PID name has the syntax
<prefix>/<generatedname>, otherwise it just returns the generated
random name (suffix for the Hand... | def generate_PID_name(self, prefix=None):
'''
Generate a unique random Handle name (random UUID). The Handle is not
registered. If a prefix is specified, the PID name has the syntax
<prefix>/<generatedname>, otherwise it just returns the generated
random name (suffix for the Hand... | [
"Generate",
"a",
"unique",
"random",
"Handle",
"name",
"(",
"random",
"UUID",
")",
".",
"The",
"Handle",
"is",
"not",
"registered",
".",
"If",
"a",
"prefix",
"is",
"specified",
"the",
"PID",
"name",
"has",
"the",
"syntax",
"<prefix",
">",
"/",
"<generate... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L975-L993 | [
"def",
"generate_PID_name",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'generate_PID_name...'",
")",
"randomuuid",
"=",
"uuid",
".",
"uuid4",
"(",
")",
"if",
"prefix",
"is",
"not",
"None",
":",
"return",
"prefix",
"+... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.get_handlerecord_indices_for_key | Finds the Handle entry indices of all entries that have a specific
type.
*Important:* It finds the Handle System indices! These are not
the python indices of the list, so they can not be used for
iteration.
:param key: The key (Handle Record type)
:param list_of_entries... | b2handle/handleclient.py | def get_handlerecord_indices_for_key(self, key, list_of_entries):
'''
Finds the Handle entry indices of all entries that have a specific
type.
*Important:* It finds the Handle System indices! These are not
the python indices of the list, so they can not be used for
itera... | def get_handlerecord_indices_for_key(self, key, list_of_entries):
'''
Finds the Handle entry indices of all entries that have a specific
type.
*Important:* It finds the Handle System indices! These are not
the python indices of the list, so they can not be used for
itera... | [
"Finds",
"the",
"Handle",
"entry",
"indices",
"of",
"all",
"entries",
"that",
"have",
"a",
"specific",
"type",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L997-L1019 | [
"def",
"get_handlerecord_indices_for_key",
"(",
"self",
",",
"key",
",",
"list_of_entries",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'get_handlerecord_indices_for_key...'",
")",
"indices",
"=",
"[",
"]",
"for",
"entry",
"in",
"list_of_entries",
":",
"if",
"entry",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__send_handle_delete_request | Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:param indices: Optional. A list of indices to delete. Defaults to
None (i.e. the... | b2handle/handleclient.py | def __send_handle_delete_request(self, handle, indices=None, op=None):
'''
Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:p... | def __send_handle_delete_request(self, handle, indices=None, op=None):
'''
Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:p... | [
"Send",
"a",
"HTTP",
"DELETE",
"request",
"to",
"the",
"handle",
"server",
"to",
"delete",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"from",
"a",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1023-L1040 | [
"def",
"__send_handle_delete_request",
"(",
"self",
",",
"handle",
",",
"indices",
"=",
"None",
",",
"op",
"=",
"None",
")",
":",
"resp",
"=",
"self",
".",
"__handlesystemconnector",
".",
"send_handle_delete_request",
"(",
"handle",
"=",
"handle",
",",
"indice... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__send_handle_put_request | Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param handle: The handle.
:param list_of_entries: A list of handle record entries to be written,
in the format [{"i... | b2handle/handleclient.py | def __send_handle_put_request(self, handle, list_of_entries, indices=None, overwrite=False, op=None):
'''
Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param hand... | def __send_handle_put_request(self, handle, list_of_entries, indices=None, overwrite=False, op=None):
'''
Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param hand... | [
"Send",
"a",
"HTTP",
"PUT",
"request",
"to",
"the",
"handle",
"server",
"to",
"write",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"to",
"an",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1042-L1066 | [
"def",
"__send_handle_put_request",
"(",
"self",
",",
"handle",
",",
"list_of_entries",
",",
"indices",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"op",
"=",
"None",
")",
":",
"resp",
",",
"payload",
"=",
"self",
".",
"__handlesystemconnector",
".",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__send_handle_get_request | Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Optional. A list of indices to delete. Defaults to
None (i.e. the enti... | b2handle/handleclient.py | def __send_handle_get_request(self, handle, indices=None):
'''
Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Opt... | def __send_handle_get_request(self, handle, indices=None):
'''
Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Opt... | [
"Send",
"a",
"HTTP",
"GET",
"request",
"to",
"the",
"handle",
"server",
"to",
"read",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"from",
"a",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1068-L1082 | [
"def",
"__send_handle_get_request",
"(",
"self",
",",
"handle",
",",
"indices",
"=",
"None",
")",
":",
"resp",
"=",
"self",
".",
"__handlesystemconnector",
".",
"send_handle_get_request",
"(",
"handle",
",",
"indices",
")",
"return",
"resp"
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__get_handle_record_if_necessary | Returns the handle record if it is None or if its handle is not the
same as the specified handle. | b2handle/handleclient.py | def __get_handle_record_if_necessary(self, handle, handlerecord_json):
'''
Returns the handle record if it is None or if its handle is not the
same as the specified handle.
'''
if handlerecord_json is None:
handlerecord_json = self.retrieve_handle_record_json(han... | def __get_handle_record_if_necessary(self, handle, handlerecord_json):
'''
Returns the handle record if it is None or if its handle is not the
same as the specified handle.
'''
if handlerecord_json is None:
handlerecord_json = self.retrieve_handle_record_json(han... | [
"Returns",
"the",
"handle",
"record",
"if",
"it",
"is",
"None",
"or",
"if",
"its",
"handle",
"is",
"not",
"the",
"same",
"as",
"the",
"specified",
"handle",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1084-L1095 | [
"def",
"__get_handle_record_if_necessary",
"(",
"self",
",",
"handle",
",",
"handlerecord_json",
")",
":",
"if",
"handlerecord_json",
"is",
"None",
":",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"else",
":",
"if",
"h... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__make_another_index | Find an index not yet used in the handle record and not reserved for
any (other) special type.
:param: list_of_entries: List of all entries to find which indices are
used already.
:param url: If True, an index for an URL entry is returned (1, unless
it is already in ... | b2handle/handleclient.py | def __make_another_index(self, list_of_entries, url=False, hs_admin=False):
'''
Find an index not yet used in the handle record and not reserved for
any (other) special type.
:param: list_of_entries: List of all entries to find which indices are
used already.
:pa... | def __make_another_index(self, list_of_entries, url=False, hs_admin=False):
'''
Find an index not yet used in the handle record and not reserved for
any (other) special type.
:param: list_of_entries: List of all entries to find which indices are
used already.
:pa... | [
"Find",
"an",
"index",
"not",
"yet",
"used",
"in",
"the",
"handle",
"record",
"and",
"not",
"reserved",
"for",
"any",
"(",
"other",
")",
"special",
"type",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1097-L1136 | [
"def",
"__make_another_index",
"(",
"self",
",",
"list_of_entries",
",",
"url",
"=",
"False",
",",
"hs_admin",
"=",
"False",
")",
":",
"start",
"=",
"2",
"# reserved indices:",
"reserved_for_url",
"=",
"set",
"(",
"[",
"1",
"]",
")",
"reserved_for_admin",
"=... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__create_entry | Create an entry of any type except HS_ADMIN.
:param entrytype: THe type of entry to create, e.g. 'URL' or
'checksum' or ... Note: For entries of type 'HS_ADMIN', please
use __create_admin_entry(). For type '10320/LOC', please use
'add_additional_URL()'
:param data: T... | b2handle/handleclient.py | def __create_entry(self, entrytype, data, index, ttl=None):
'''
Create an entry of any type except HS_ADMIN.
:param entrytype: THe type of entry to create, e.g. 'URL' or
'checksum' or ... Note: For entries of type 'HS_ADMIN', please
use __create_admin_entry(). For type '... | def __create_entry(self, entrytype, data, index, ttl=None):
'''
Create an entry of any type except HS_ADMIN.
:param entrytype: THe type of entry to create, e.g. 'URL' or
'checksum' or ... Note: For entries of type 'HS_ADMIN', please
use __create_admin_entry(). For type '... | [
"Create",
"an",
"entry",
"of",
"any",
"type",
"except",
"HS_ADMIN",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1138-L1165 | [
"def",
"__create_entry",
"(",
"self",
",",
"entrytype",
",",
"data",
",",
"index",
",",
"ttl",
"=",
"None",
")",
":",
"if",
"entrytype",
"==",
"'HS_ADMIN'",
":",
"op",
"=",
"'creating HS_ADMIN entry'",
"msg",
"=",
"'This method can not create HS_ADMIN entries.'",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__create_admin_entry | Create an entry of type "HS_ADMIN".
:param username: The username, i.e. a handle with an index
(index:prefix/suffix). The value referenced by the index contains
authentcation information, e.g. a hidden entry containing a key.
:param permissions: The permissions as a string of ze... | b2handle/handleclient.py | def __create_admin_entry(self, handleowner, permissions, index, handle, ttl=None):
'''
Create an entry of type "HS_ADMIN".
:param username: The username, i.e. a handle with an index
(index:prefix/suffix). The value referenced by the index contains
authentcation informati... | def __create_admin_entry(self, handleowner, permissions, index, handle, ttl=None):
'''
Create an entry of type "HS_ADMIN".
:param username: The username, i.e. a handle with an index
(index:prefix/suffix). The value referenced by the index contains
authentcation informati... | [
"Create",
"an",
"entry",
"of",
"type",
"HS_ADMIN",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1167-L1206 | [
"def",
"__create_admin_entry",
"(",
"self",
",",
"handleowner",
",",
"permissions",
",",
"index",
",",
"handle",
",",
"ttl",
"=",
"None",
")",
":",
"# If the handle owner is specified, use it. Otherwise, use 200:0.NA/prefix",
"# With the prefix taken from the handle that is bei... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__get_python_indices_for_key | Finds the indices of all entries that have a specific type. Important:
This method finds the python indices of the list of entries! These
are not the Handle System index values!
:param key: The key (Handle Record type)
:param list_of_entries: A list of the existing entries in wh... | b2handle/handleclient.py | def __get_python_indices_for_key(self, key, list_of_entries):
'''
Finds the indices of all entries that have a specific type. Important:
This method finds the python indices of the list of entries! These
are not the Handle System index values!
:param key: The key (Handle... | def __get_python_indices_for_key(self, key, list_of_entries):
'''
Finds the indices of all entries that have a specific type. Important:
This method finds the python indices of the list of entries! These
are not the Handle System index values!
:param key: The key (Handle... | [
"Finds",
"the",
"indices",
"of",
"all",
"entries",
"that",
"have",
"a",
"specific",
"type",
".",
"Important",
":",
"This",
"method",
"finds",
"the",
"python",
"indices",
"of",
"the",
"list",
"of",
"entries!",
"These",
"are",
"not",
"the",
"Handle",
"System... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1208-L1224 | [
"def",
"__get_python_indices_for_key",
"(",
"self",
",",
"key",
",",
"list_of_entries",
")",
":",
"indices",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"list_of_entries",
")",
")",
":",
"if",
"list_of_entries",
"[",
"i",
"]",
"[",
"'type... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__exchange_URL_in_13020loc | Exchange every occurrence of oldurl against newurl in a 10320/LOC entry.
This does not change the ids or other xml attributes of the
<location> element.
:param oldurl: The URL that will be overwritten.
:param newurl: The URL to write into the entry.
:param list_of_entrie... | b2handle/handleclient.py | def __exchange_URL_in_13020loc(self, oldurl, newurl, list_of_entries, handle):
'''
Exchange every occurrence of oldurl against newurl in a 10320/LOC entry.
This does not change the ids or other xml attributes of the
<location> element.
:param oldurl: The URL that will be... | def __exchange_URL_in_13020loc(self, oldurl, newurl, list_of_entries, handle):
'''
Exchange every occurrence of oldurl against newurl in a 10320/LOC entry.
This does not change the ids or other xml attributes of the
<location> element.
:param oldurl: The URL that will be... | [
"Exchange",
"every",
"occurrence",
"of",
"oldurl",
"against",
"newurl",
"in",
"a",
"10320",
"/",
"LOC",
"entry",
".",
"This",
"does",
"not",
"change",
"the",
"ids",
"or",
"other",
"xml",
"attributes",
"of",
"the",
"<location",
">",
"element",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1226-L1271 | [
"def",
"__exchange_URL_in_13020loc",
"(",
"self",
",",
"oldurl",
",",
"newurl",
",",
"list_of_entries",
",",
"handle",
")",
":",
"# Find existing 10320/LOC entries",
"python_indices",
"=",
"self",
".",
"__get_python_indices_for_key",
"(",
"'10320/LOC'",
",",
"list_of_en... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__remove_URL_from_10320LOC | Remove an URL from the handle record's "10320/LOC" entry.
If it exists several times in the entry, all occurences are removed.
If the URL is not present, nothing happens.
If after removing, there is no more URLs in the entry, the entry is
removed.
:param url: The URL to be r... | b2handle/handleclient.py | def __remove_URL_from_10320LOC(self, url, list_of_entries, handle):
'''
Remove an URL from the handle record's "10320/LOC" entry.
If it exists several times in the entry, all occurences are removed.
If the URL is not present, nothing happens.
If after removing, there is no more U... | def __remove_URL_from_10320LOC(self, url, list_of_entries, handle):
'''
Remove an URL from the handle record's "10320/LOC" entry.
If it exists several times in the entry, all occurences are removed.
If the URL is not present, nothing happens.
If after removing, there is no more U... | [
"Remove",
"an",
"URL",
"from",
"the",
"handle",
"record",
"s",
"10320",
"/",
"LOC",
"entry",
".",
"If",
"it",
"exists",
"several",
"times",
"in",
"the",
"entry",
"all",
"occurences",
"are",
"removed",
".",
"If",
"the",
"URL",
"is",
"not",
"present",
"n... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1273-L1327 | [
"def",
"__remove_URL_from_10320LOC",
"(",
"self",
",",
"url",
",",
"list_of_entries",
",",
"handle",
")",
":",
"# Find existing 10320/LOC entries",
"python_indices",
"=",
"self",
".",
"__get_python_indices_for_key",
"(",
"'10320/LOC'",
",",
"list_of_entries",
")",
"num_... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__add_URL_to_10320LOC | Add a url to the handle record's "10320/LOC" entry.
If no 10320/LOC entry exists, a new one is created (using the
default "chooseby" attribute, if configured).
If the URL is already present, it is not added again, but
the attributes (e.g. weight) are updated/added.
... | b2handle/handleclient.py | def __add_URL_to_10320LOC(self, url, list_of_entries, handle=None, weight=None, http_role=None, **kvpairs):
'''
Add a url to the handle record's "10320/LOC" entry.
If no 10320/LOC entry exists, a new one is created (using the
default "chooseby" attribute, if configured).
... | def __add_URL_to_10320LOC(self, url, list_of_entries, handle=None, weight=None, http_role=None, **kvpairs):
'''
Add a url to the handle record's "10320/LOC" entry.
If no 10320/LOC entry exists, a new one is created (using the
default "chooseby" attribute, if configured).
... | [
"Add",
"a",
"url",
"to",
"the",
"handle",
"record",
"s",
"10320",
"/",
"LOC",
"entry",
".",
"If",
"no",
"10320",
"/",
"LOC",
"entry",
"exists",
"a",
"new",
"one",
"is",
"created",
"(",
"using",
"the",
"default",
"chooseby",
"attribute",
"if",
"configur... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1329-L1417 | [
"def",
"__add_URL_to_10320LOC",
"(",
"self",
",",
"url",
",",
"list_of_entries",
",",
"handle",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"http_role",
"=",
"None",
",",
"*",
"*",
"kvpairs",
")",
":",
"# Find existing 10320/LOC entry or create new",
"indices"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | EUDATHandleClient.__set_or_adapt_10320LOC_attributes | Adds or updates attributes of a <location> element. Existing attributes
are not removed!
:param locelement: A location element as xml snippet
(xml.etree.ElementTree.Element).
:param weight: Optional. The weight to be set (integer between 0 and
1). If None, no weight ... | b2handle/handleclient.py | def __set_or_adapt_10320LOC_attributes(self, locelement, weight=None, http_role=None, **kvpairs):
'''
Adds or updates attributes of a <location> element. Existing attributes
are not removed!
:param locelement: A location element as xml snippet
(xml.etree.ElementTree.Elem... | def __set_or_adapt_10320LOC_attributes(self, locelement, weight=None, http_role=None, **kvpairs):
'''
Adds or updates attributes of a <location> element. Existing attributes
are not removed!
:param locelement: A location element as xml snippet
(xml.etree.ElementTree.Elem... | [
"Adds",
"or",
"updates",
"attributes",
"of",
"a",
"<location",
">",
"element",
".",
"Existing",
"attributes",
"are",
"not",
"removed!"
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1419-L1451 | [
"def",
"__set_or_adapt_10320LOC_attributes",
"(",
"self",
",",
"locelement",
",",
"weight",
"=",
"None",
",",
"http_role",
"=",
"None",
",",
"*",
"*",
"kvpairs",
")",
":",
"if",
"weight",
"is",
"not",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'__set_or_ad... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | WeiboOauth2.authorize_url | authorization url
request weibo authorization url
:return:
code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。
state string 如果传递参数,会回传该参数 | weibopy/auth.py | def authorize_url(self):
"""
authorization url
request weibo authorization url
:return:
code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。
state string 如果传递参数,会回传该参数
"""
if self.oauth2_params and self.oauth2_params.get("display") == ... | def authorize_url(self):
"""
authorization url
request weibo authorization url
:return:
code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。
state string 如果传递参数,会回传该参数
"""
if self.oauth2_params and self.oauth2_params.get("display") == ... | [
"authorization",
"url",
"request",
"weibo",
"authorization",
"url",
":",
"return",
":",
"code",
"string",
"用于第二步调用oauth2",
"/",
"access_token接口,获取授权后的access",
"token。",
"state",
"string",
"如果传递参数,会回传该参数"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L68-L90 | [
"def",
"authorize_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"oauth2_params",
"and",
"self",
".",
"oauth2_params",
".",
"get",
"(",
"\"display\"",
")",
"==",
"\"mobile\"",
":",
"auth_url",
"=",
"self",
".",
"mobile_url",
"+",
"\"authorize\"",
"else",
... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboOauth2.request | :param method: str, http method ["GET","POST","PUT"]
:param suffix: the url suffix
:param data:
:return: | weibopy/auth.py | def request(self, method, suffix, data):
"""
:param method: str, http method ["GET","POST","PUT"]
:param suffix: the url suffix
:param data:
:return:
"""
url = self.site_url + suffix
response = self.session.request(method, url, data=data)
if respo... | def request(self, method, suffix, data):
"""
:param method: str, http method ["GET","POST","PUT"]
:param suffix: the url suffix
:param data:
:return:
"""
url = self.site_url + suffix
response = self.session.request(method, url, data=data)
if respo... | [
":",
"param",
"method",
":",
"str",
"http",
"method",
"[",
"GET",
"POST",
"PUT",
"]",
":",
"param",
"suffix",
":",
"the",
"url",
"suffix",
":",
"param",
"data",
":",
":",
"return",
":"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L92-L123 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"suffix",
",",
"data",
")",
":",
"url",
"=",
"self",
".",
"site_url",
"+",
"suffix",
"response",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
",",
"url",
",",
"data",
"=",
"data",
")... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboOauth2.auth_access | verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值里的UID
字段来做登录识别。
... | weibopy/auth.py | def auth_access(self, auth_code):
"""
verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值... | def auth_access(self, auth_code):
"""
verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值... | [
"verify",
"the",
"fist",
"authorization",
"response",
"url",
"code"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L125-L166 | [
"def",
"auth_access",
"(",
"self",
",",
"auth_code",
")",
":",
"data",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"a... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboOauth2.revoke_auth_access | 授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return: bool | weibopy/auth.py | def revoke_auth_access(self, access_token):
"""
授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return... | def revoke_auth_access(self, access_token):
"""
授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return... | [
"授权回收接口,帮助开发者主动取消用户的授权。"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L168-L183 | [
"def",
"revoke_auth_access",
"(",
"self",
",",
"access_token",
")",
":",
"result",
"=",
"self",
".",
"request",
"(",
"\"post\"",
",",
"\"revokeoauth2\"",
",",
"data",
"=",
"{",
"\"access_token\"",
":",
"access_token",
"}",
")",
"return",
"bool",
"(",
"result... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | HandleSystemConnector.__set_basic_auth_string | Creates and sets the authentication string for (write-)accessing the
Handle Server. No return, the string is set as an attribute to
the client instance.
:param username: Username handle with index: index:prefix/suffix.
:param password: The password contained in the index of the ... | b2handle/handlesystemconnector.py | def __set_basic_auth_string(self, username, password):
'''
Creates and sets the authentication string for (write-)accessing the
Handle Server. No return, the string is set as an attribute to
the client instance.
:param username: Username handle with index: index:prefix/s... | def __set_basic_auth_string(self, username, password):
'''
Creates and sets the authentication string for (write-)accessing the
Handle Server. No return, the string is set as an attribute to
the client instance.
:param username: Username handle with index: index:prefix/s... | [
"Creates",
"and",
"sets",
"the",
"authentication",
"string",
"for",
"(",
"write",
"-",
")",
"accessing",
"the",
"Handle",
"Server",
".",
"No",
"return",
"the",
"string",
"is",
"set",
"as",
"an",
"attribute",
"to",
"the",
"client",
"instance",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L236-L247 | [
"def",
"__set_basic_auth_string",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"auth",
"=",
"b2handle",
".",
"utilhandle",
".",
"create_authentication_string",
"(",
"username",
",",
"password",
")",
"self",
".",
"__basic_authentication_string",
"=",
"a... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.send_handle_get_request | Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Optional. A list of indices to delete. Defaults to
None (i.e. the enti... | b2handle/handlesystemconnector.py | def send_handle_get_request(self, handle, indices=None):
'''
Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Optio... | def send_handle_get_request(self, handle, indices=None):
'''
Send a HTTP GET request to the handle server to read either an entire
handle or to some specified values from a handle record, using the
requests module.
:param handle: The handle.
:param indices: Optio... | [
"Send",
"a",
"HTTP",
"GET",
"request",
"to",
"the",
"handle",
"server",
"to",
"read",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"from",
"a",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L252-L292 | [
"def",
"send_handle_get_request",
"(",
"self",
",",
"handle",
",",
"indices",
"=",
"None",
")",
":",
"# Assemble required info:",
"url",
"=",
"self",
".",
"make_handle_URL",
"(",
"handle",
",",
"indices",
")",
"LOGGER",
".",
"debug",
"(",
"'GET Request to '",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.send_handle_put_request | Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param handle: The handle.
:param list_of_entries: A list of handle record entries to be written,
in the format [{"i... | b2handle/handlesystemconnector.py | def send_handle_put_request(self, **args):
'''
Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param handle: The handle.
:param list_of_entries: A list of h... | def send_handle_put_request(self, **args):
'''
Send a HTTP PUT request to the handle server to write either an entire
handle or to some specified values to an handle record, using the
requests module.
:param handle: The handle.
:param list_of_entries: A list of h... | [
"Send",
"a",
"HTTP",
"PUT",
"request",
"to",
"the",
"handle",
"server",
"to",
"write",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"to",
"an",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L301-L356 | [
"def",
"send_handle_put_request",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"# Check if we have write access at all:",
"if",
"not",
"self",
".",
"__has_write_access",
":",
"raise",
"HandleAuthenticationError",
"(",
"msg",
"=",
"self",
".",
"__no_auth_message",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.send_handle_delete_request | Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:param indices: Optional. A list of indices to delete. Defaults to
None (i.e. the... | b2handle/handlesystemconnector.py | def send_handle_delete_request(self, **args):
'''
Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:param indices: Optional. A... | def send_handle_delete_request(self, **args):
'''
Send a HTTP DELETE request to the handle server to delete either an
entire handle or to some specified values from a handle record,
using the requests module.
:param handle: The handle.
:param indices: Optional. A... | [
"Send",
"a",
"HTTP",
"DELETE",
"request",
"to",
"the",
"handle",
"server",
"to",
"delete",
"either",
"an",
"entire",
"handle",
"or",
"to",
"some",
"specified",
"values",
"from",
"a",
"handle",
"record",
"using",
"the",
"requests",
"module",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L384-L445 | [
"def",
"send_handle_delete_request",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"# Check if we have write access at all:",
"if",
"not",
"self",
".",
"__has_write_access",
":",
"raise",
"HandleAuthenticationError",
"(",
"msg",
"=",
"self",
".",
"__no_auth_message",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.check_if_username_exists | Check if the username handles exists.
:param username: The username, in the form index:prefix/suffix
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException`
:raises: :exc:`~b2handle.handleexceptions.GenericHandleError`
:return: True. If it does not exist, an exception is rais... | b2handle/handlesystemconnector.py | def check_if_username_exists(self, username):
'''
Check if the username handles exists.
:param username: The username, in the form index:prefix/suffix
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException`
:raises: :exc:`~b2handle.handleexceptions.GenericHandleError`... | def check_if_username_exists(self, username):
'''
Check if the username handles exists.
:param username: The username, in the form index:prefix/suffix
:raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException`
:raises: :exc:`~b2handle.handleexceptions.GenericHandleError`... | [
"Check",
"if",
"the",
"username",
"handles",
"exists",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L447-L482 | [
"def",
"check_if_username_exists",
"(",
"self",
",",
"username",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'check_if_username_exists...'",
")",
"_",
",",
"handle",
"=",
"b2handle",
".",
"utilhandle",
".",
"remove_index_from_handle",
"(",
"username",
")",
"resp",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.__get_headers | Create HTTP headers for different HTTP requests. Content-type and
Accept are 'application/json', as the library is interacting with
a REST API.
:param action: Action for which to create the header ('GET', 'PUT',
'DELETE', 'SEARCH').
:return: dict containing key-value... | b2handle/handlesystemconnector.py | def __get_headers(self, action):
'''
Create HTTP headers for different HTTP requests. Content-type and
Accept are 'application/json', as the library is interacting with
a REST API.
:param action: Action for which to create the header ('GET', 'PUT',
'DELETE', ... | def __get_headers(self, action):
'''
Create HTTP headers for different HTTP requests. Content-type and
Accept are 'application/json', as the library is interacting with
a REST API.
:param action: Action for which to create the header ('GET', 'PUT',
'DELETE', ... | [
"Create",
"HTTP",
"headers",
"for",
"different",
"HTTP",
"requests",
".",
"Content",
"-",
"type",
"and",
"Accept",
"are",
"application",
"/",
"json",
"as",
"the",
"library",
"is",
"interacting",
"with",
"a",
"REST",
"API",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L484-L517 | [
"def",
"__get_headers",
"(",
"self",
",",
"action",
")",
":",
"header",
"=",
"{",
"}",
"accept",
"=",
"'application/json'",
"content_type",
"=",
"'application/json'",
"if",
"action",
"is",
"'GET'",
":",
"header",
"[",
"'Accept'",
"]",
"=",
"accept",
"elif",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | HandleSystemConnector.make_handle_URL | Create the URL for a HTTP request (URL + query string) to request
a specific handle from the Handle Server.
:param handle: The handle to access.
:param indices: Optional. A list of integers or strings. Indices of
the handle record entries to read or write. Defaults to None.
... | b2handle/handlesystemconnector.py | def make_handle_URL(self, handle, indices=None, overwrite=None, other_url=None):
'''
Create the URL for a HTTP request (URL + query string) to request
a specific handle from the Handle Server.
:param handle: The handle to access.
:param indices: Optional. A list of integers or s... | def make_handle_URL(self, handle, indices=None, overwrite=None, other_url=None):
'''
Create the URL for a HTTP request (URL + query string) to request
a specific handle from the Handle Server.
:param handle: The handle to access.
:param indices: Optional. A list of integers or s... | [
"Create",
"the",
"URL",
"for",
"a",
"HTTP",
"request",
"(",
"URL",
"+",
"query",
"string",
")",
"to",
"request",
"a",
"specific",
"handle",
"from",
"the",
"Handle",
"Server",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L519-L561 | [
"def",
"make_handle_URL",
"(",
"self",
",",
"handle",
",",
"indices",
"=",
"None",
",",
"overwrite",
"=",
"None",
",",
"other_url",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'make_handle_URL...'",
")",
"separator",
"=",
"'?'",
"if",
"other_url",... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | CarbonClientService.publish_metric | Record a single hit on a given metric.
Args:
metric_name: The name of the metric to record with Carbon.
metric_value: The value to record with Carbon.
epoch_seconds: Optionally specify the time for the metric hit.
Returns:
None | src/txCarbonClient/carbon_client_service.py | def publish_metric(self, metric_name, metric_value, epoch_seconds=None):
'''Record a single hit on a given metric.
Args:
metric_name: The name of the metric to record with Carbon.
metric_value: The value to record with Carbon.
epoch_seconds: Optionally specify the ti... | def publish_metric(self, metric_name, metric_value, epoch_seconds=None):
'''Record a single hit on a given metric.
Args:
metric_name: The name of the metric to record with Carbon.
metric_value: The value to record with Carbon.
epoch_seconds: Optionally specify the ti... | [
"Record",
"a",
"single",
"hit",
"on",
"a",
"given",
"metric",
"."
] | fdChasm/txCarbonClient | python | https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L30-L44 | [
"def",
"publish_metric",
"(",
"self",
",",
"metric_name",
",",
"metric_value",
",",
"epoch_seconds",
"=",
"None",
")",
":",
"if",
"epoch_seconds",
"is",
"None",
":",
"epoch_seconds",
"=",
"self",
".",
"_reactor",
".",
"seconds",
"(",
")",
"self",
".",
"_cl... | c342eff1957d281cba3c83fc578f08c4bf9fcd03 |
train | CarbonClientService.register_repeating_metric | Record hits to a metric at a specified interval.
Args:
metric_name: The name of the metric to record with Carbon.
frequency: The frequency with which to poll the getter and record the value with Carbon.
getter: A function which takes no arguments and returns the value to rec... | src/txCarbonClient/carbon_client_service.py | def register_repeating_metric(self, metric_name, frequency, getter):
'''Record hits to a metric at a specified interval.
Args:
metric_name: The name of the metric to record with Carbon.
frequency: The frequency with which to poll the getter and record the value with Carbon.
... | def register_repeating_metric(self, metric_name, frequency, getter):
'''Record hits to a metric at a specified interval.
Args:
metric_name: The name of the metric to record with Carbon.
frequency: The frequency with which to poll the getter and record the value with Carbon.
... | [
"Record",
"hits",
"to",
"a",
"metric",
"at",
"a",
"specified",
"interval",
"."
] | fdChasm/txCarbonClient | python | https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L46-L63 | [
"def",
"register_repeating_metric",
"(",
"self",
",",
"metric_name",
",",
"frequency",
",",
"getter",
")",
":",
"l",
"=",
"task",
".",
"LoopingCall",
"(",
"self",
".",
"_publish_repeating_metric",
",",
"metric_name",
",",
"getter",
")",
"repeating_metric_handle",
... | c342eff1957d281cba3c83fc578f08c4bf9fcd03 |
train | setup | Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Arguments:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, default
provided by P... | pyblish_nuke/lib.py | def setup(console=False, port=None, menu=True):
"""Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Arguments:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to conn... | def setup(console=False, port=None, menu=True):
"""Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Arguments:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to conn... | [
"Setup",
"integration"
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L28-L52 | [
"def",
"setup",
"(",
"console",
"=",
"False",
",",
"port",
"=",
"None",
",",
"menu",
"=",
"True",
")",
":",
"if",
"self",
".",
"_has_been_setup",
":",
"teardown",
"(",
")",
"register_plugins",
"(",
")",
"register_host",
"(",
")",
"if",
"menu",
":",
"... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | show | Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user. | pyblish_nuke/lib.py | def show():
"""Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user.
"""
parent = None
current = QtWidgets.QApplication.activeWindow()
while current:
parent = current
cur... | def show():
"""Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user.
"""
parent = None
current = QtWidgets.QApplication.activeWindow()
while current:
parent = current
cur... | [
"Try",
"showing",
"the",
"most",
"desirable",
"GUI"
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L55-L72 | [
"def",
"show",
"(",
")",
":",
"parent",
"=",
"None",
"current",
"=",
"QtWidgets",
".",
"QApplication",
".",
"activeWindow",
"(",
")",
"while",
"current",
":",
"parent",
"=",
"current",
"current",
"=",
"parent",
".",
"parent",
"(",
")",
"window",
"=",
"... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | _nuke_set_zero_margins | Remove Nuke margins when docked UI
.. _More info:
https://gist.github.com/maty974/4739917 | pyblish_nuke/lib.py | def _nuke_set_zero_margins(widget_object):
"""Remove Nuke margins when docked UI
.. _More info:
https://gist.github.com/maty974/4739917
"""
parentApp = QtWidgets.QApplication.allWidgets()
parentWidgetList = []
for parent in parentApp:
for child in parent.children():
i... | def _nuke_set_zero_margins(widget_object):
"""Remove Nuke margins when docked UI
.. _More info:
https://gist.github.com/maty974/4739917
"""
parentApp = QtWidgets.QApplication.allWidgets()
parentWidgetList = []
for parent in parentApp:
for child in parent.children():
i... | [
"Remove",
"Nuke",
"margins",
"when",
"docked",
"UI",
"..",
"_More",
"info",
":",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"maty974",
"/",
"4739917"
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L303-L325 | [
"def",
"_nuke_set_zero_margins",
"(",
"widget_object",
")",
":",
"parentApp",
"=",
"QtWidgets",
".",
"QApplication",
".",
"allWidgets",
"(",
")",
"parentWidgetList",
"=",
"[",
"]",
"for",
"parent",
"in",
"parentApp",
":",
"for",
"child",
"in",
"parent",
".",
... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | dock | Expecting a window to parent into a Nuke panel, that is dockable. | pyblish_nuke/lib.py | def dock(window):
""" Expecting a window to parent into a Nuke panel, that is dockable. """
# Deleting existing dock
# There is a bug where existing docks are kept in-memory when closed via UI
if self._dock:
print("Deleting existing dock...")
parent = self._dock
dialog = None
... | def dock(window):
""" Expecting a window to parent into a Nuke panel, that is dockable. """
# Deleting existing dock
# There is a bug where existing docks are kept in-memory when closed via UI
if self._dock:
print("Deleting existing dock...")
parent = self._dock
dialog = None
... | [
"Expecting",
"a",
"window",
"to",
"parent",
"into",
"a",
"Nuke",
"panel",
"that",
"is",
"dockable",
"."
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L335-L379 | [
"def",
"dock",
"(",
"window",
")",
":",
"# Deleting existing dock",
"# There is a bug where existing docks are kept in-memory when closed via UI",
"if",
"self",
".",
"_dock",
":",
"print",
"(",
"\"Deleting existing dock...\"",
")",
"parent",
"=",
"self",
".",
"_dock",
"di... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | remove_index_from_handle | Returns index and handle separately, in a tuple.
:handle_with_index: The handle string with an index (e.g.
500:prefix/suffix)
:return: index and handle as a tuple. | b2handle/utilhandle.py | def remove_index_from_handle(handle_with_index):
'''
Returns index and handle separately, in a tuple.
:handle_with_index: The handle string with an index (e.g.
500:prefix/suffix)
:return: index and handle as a tuple.
'''
split = handle_with_index.split(':')
if len(split) == 2:
... | def remove_index_from_handle(handle_with_index):
'''
Returns index and handle separately, in a tuple.
:handle_with_index: The handle string with an index (e.g.
500:prefix/suffix)
:return: index and handle as a tuple.
'''
split = handle_with_index.split(':')
if len(split) == 2:
... | [
"Returns",
"index",
"and",
"handle",
"separately",
"in",
"a",
"tuple",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L14-L33 | [
"def",
"remove_index_from_handle",
"(",
"handle_with_index",
")",
":",
"split",
"=",
"handle_with_index",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"split",
")",
"==",
"2",
":",
"split",
"[",
"0",
"]",
"=",
"int",
"(",
"split",
"[",
"0",
"]",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | check_handle_syntax | Checks the syntax of a handle without an index (are prefix
and suffix there, are there too many slashes?).
:string: The handle without index, as string prefix/suffix.
:raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError`
:return: True. If it's not ok, exceptions are raised. | b2handle/utilhandle.py | def check_handle_syntax(string):
'''
Checks the syntax of a handle without an index (are prefix
and suffix there, are there too many slashes?).
:string: The handle without index, as string prefix/suffix.
:raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError`
:return: True.... | def check_handle_syntax(string):
'''
Checks the syntax of a handle without an index (are prefix
and suffix there, are there too many slashes?).
:string: The handle without index, as string prefix/suffix.
:raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError`
:return: True.... | [
"Checks",
"the",
"syntax",
"of",
"a",
"handle",
"without",
"an",
"index",
"(",
"are",
"prefix",
"and",
"suffix",
"there",
"are",
"there",
"too",
"many",
"slashes?",
")",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L35-L68 | [
"def",
"check_handle_syntax",
"(",
"string",
")",
":",
"expected",
"=",
"'prefix/suffix'",
"try",
":",
"arr",
"=",
"string",
".",
"split",
"(",
"'/'",
")",
"except",
"AttributeError",
":",
"raise",
"handleexceptions",
".",
"HandleSyntaxError",
"(",
"msg",
"=",... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | create_authentication_string | Creates an authentication string from the username and password.
:username: Username.
:password: Password.
:return: The encoded string. | b2handle/utilhandle.py | def create_authentication_string(username, password):
'''
Creates an authentication string from the username and password.
:username: Username.
:password: Password.
:return: The encoded string.
'''
username_utf8 = username.encode('utf-8')
userpw_utf8 = password.encode('utf-8')
user... | def create_authentication_string(username, password):
'''
Creates an authentication string from the username and password.
:username: Username.
:password: Password.
:return: The encoded string.
'''
username_utf8 = username.encode('utf-8')
userpw_utf8 = password.encode('utf-8')
user... | [
"Creates",
"an",
"authentication",
"string",
"from",
"the",
"username",
"and",
"password",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L102-L118 | [
"def",
"create_authentication_string",
"(",
"username",
",",
"password",
")",
":",
"username_utf8",
"=",
"username",
".",
"encode",
"(",
"'utf-8'",
")",
"userpw_utf8",
"=",
"password",
".",
"encode",
"(",
"'utf-8'",
")",
"username_perc",
"=",
"quote",
"(",
"us... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | make_request_log_message | Creates a string containing all relevant information
about a request made to the Handle System, for
logging purposes.
:handle: The handle that the request is about.
:url: The url the request is sent to.
:headers: The headers sent along with the request.
:verify: Boolean parameter passed to the ... | b2handle/utilhandle.py | def make_request_log_message(**args):
'''
Creates a string containing all relevant information
about a request made to the Handle System, for
logging purposes.
:handle: The handle that the request is about.
:url: The url the request is sent to.
:headers: The headers sent along with the requ... | def make_request_log_message(**args):
'''
Creates a string containing all relevant information
about a request made to the Handle System, for
logging purposes.
:handle: The handle that the request is about.
:url: The url the request is sent to.
:headers: The headers sent along with the requ... | [
"Creates",
"a",
"string",
"containing",
"all",
"relevant",
"information",
"about",
"a",
"request",
"made",
"to",
"the",
"Handle",
"System",
"for",
"logging",
"purposes",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L120-L154 | [
"def",
"make_request_log_message",
"(",
"*",
"*",
"args",
")",
":",
"mandatory_args",
"=",
"[",
"'op'",
",",
"'handle'",
",",
"'url'",
",",
"'headers'",
",",
"'verify'",
",",
"'resp'",
"]",
"optional_args",
"=",
"[",
"'payload'",
"]",
"util",
".",
"check_p... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | request_xml | Returns an etree.XMLRoot object loaded from the url
:param str url: URL for the resource to load as an XML | thredds_crawler/crawl.py | def request_xml(url, auth=None):
'''
Returns an etree.XMLRoot object loaded from the url
:param str url: URL for the resource to load as an XML
'''
try:
r = requests.get(url, auth=auth, verify=False)
return r.text.encode('utf-8')
except BaseException:
logger.error("Skippi... | def request_xml(url, auth=None):
'''
Returns an etree.XMLRoot object loaded from the url
:param str url: URL for the resource to load as an XML
'''
try:
r = requests.get(url, auth=auth, verify=False)
return r.text.encode('utf-8')
except BaseException:
logger.error("Skippi... | [
"Returns",
"an",
"etree",
".",
"XMLRoot",
"object",
"loaded",
"from",
"the",
"url",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"resource",
"to",
"load",
"as",
"an",
"XML"
] | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L35-L45 | [
"def",
"request_xml",
"(",
"url",
",",
"auth",
"=",
"None",
")",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"auth",
",",
"verify",
"=",
"False",
")",
"return",
"r",
".",
"text",
".",
"encode",
"(",
"'utf-8'",... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Crawl._get_catalog_url | Returns the appropriate catalog URL by replacing html with xml in some
cases
:param str url: URL to the catalog | thredds_crawler/crawl.py | def _get_catalog_url(self, url):
'''
Returns the appropriate catalog URL by replacing html with xml in some
cases
:param str url: URL to the catalog
'''
u = urlparse.urlsplit(url)
name, ext = os.path.splitext(u.path)
if ext == ".html":
u = urlp... | def _get_catalog_url(self, url):
'''
Returns the appropriate catalog URL by replacing html with xml in some
cases
:param str url: URL to the catalog
'''
u = urlparse.urlsplit(url)
name, ext = os.path.splitext(u.path)
if ext == ".html":
u = urlp... | [
"Returns",
"the",
"appropriate",
"catalog",
"URL",
"by",
"replacing",
"html",
"with",
"xml",
"in",
"some",
"cases",
":",
"param",
"str",
"url",
":",
"URL",
"to",
"the",
"catalog"
] | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L133-L144 | [
"def",
"_get_catalog_url",
"(",
"self",
",",
"url",
")",
":",
"u",
"=",
"urlparse",
".",
"urlsplit",
"(",
"url",
")",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"u",
".",
"path",
")",
"if",
"ext",
"==",
"\".html\"",
":",
"u... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Crawl._yield_leaves | Yields a URL corresponding to a leaf dataset for each dataset described by the catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree | thredds_crawler/crawl.py | def _yield_leaves(self, url, tree):
'''
Yields a URL corresponding to a leaf dataset for each dataset described by the catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree
'''
for leaf in tree.findall('.//{%s}dataset[@urlPat... | def _yield_leaves(self, url, tree):
'''
Yields a URL corresponding to a leaf dataset for each dataset described by the catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree
'''
for leaf in tree.findall('.//{%s}dataset[@urlPat... | [
"Yields",
"a",
"URL",
"corresponding",
"to",
"a",
"leaf",
"dataset",
"for",
"each",
"dataset",
"described",
"by",
"the",
"catalog",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"current",
"catalog",
":",
"param",
"lxml",
".",
"etree",
".",
"Elee... | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L146-L185 | [
"def",
"_yield_leaves",
"(",
"self",
",",
"url",
",",
"tree",
")",
":",
"for",
"leaf",
"in",
"tree",
".",
"findall",
"(",
"'.//{%s}dataset[@urlPath]'",
"%",
"INV_NS",
")",
":",
"# Subset by the skips",
"name",
"=",
"leaf",
".",
"get",
"(",
"\"name\"",
")",... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Crawl._compile_references | Returns a list of catalog reference URLs for the current catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree | thredds_crawler/crawl.py | def _compile_references(self, url, tree):
'''
Returns a list of catalog reference URLs for the current catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree
'''
references = []
for ref in tree.findall('.//{%s}catalogR... | def _compile_references(self, url, tree):
'''
Returns a list of catalog reference URLs for the current catalog
:param str url: URL for the current catalog
:param lxml.etree.Eleemnt tree: Current XML Tree
'''
references = []
for ref in tree.findall('.//{%s}catalogR... | [
"Returns",
"a",
"list",
"of",
"catalog",
"reference",
"URLs",
"for",
"the",
"current",
"catalog",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"current",
"catalog",
":",
"param",
"lxml",
".",
"etree",
".",
"Eleemnt",
"tree",
":",
"Current",
"XML... | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L187-L201 | [
"def",
"_compile_references",
"(",
"self",
",",
"url",
",",
"tree",
")",
":",
"references",
"=",
"[",
"]",
"for",
"ref",
"in",
"tree",
".",
"findall",
"(",
"'.//{%s}catalogRef'",
"%",
"INV_NS",
")",
":",
"# Check skips",
"title",
"=",
"ref",
".",
"get",
... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Crawl._run | Performs a multiprocess depth-first-search of the catalog references
and yields a URL for each leaf dataset found
:param str url: URL for the current catalog
:param requests.auth.AuthBase auth: requets auth object to use | thredds_crawler/crawl.py | def _run(self, url, auth):
'''
Performs a multiprocess depth-first-search of the catalog references
and yields a URL for each leaf dataset found
:param str url: URL for the current catalog
:param requests.auth.AuthBase auth: requets auth object to use
'''
if url i... | def _run(self, url, auth):
'''
Performs a multiprocess depth-first-search of the catalog references
and yields a URL for each leaf dataset found
:param str url: URL for the current catalog
:param requests.auth.AuthBase auth: requets auth object to use
'''
if url i... | [
"Performs",
"a",
"multiprocess",
"depth",
"-",
"first",
"-",
"search",
"of",
"the",
"catalog",
"references",
"and",
"yields",
"a",
"URL",
"for",
"each",
"leaf",
"dataset",
"found",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"current",
"catalog",... | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L203-L221 | [
"def",
"_run",
"(",
"self",
",",
"url",
",",
"auth",
")",
":",
"if",
"url",
"in",
"self",
".",
"visited",
":",
"logger",
".",
"debug",
"(",
"\"Skipping %s (already crawled)\"",
"%",
"url",
")",
"return",
"self",
".",
"visited",
".",
"append",
"(",
"url... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Crawl._build_catalog | Recursive function to perform the DFS and yield the leaf datasets
:param str url: URL for the current catalog
:param str xml_content: XML Body returned from HTTP Request | thredds_crawler/crawl.py | def _build_catalog(self, url, xml_content):
'''
Recursive function to perform the DFS and yield the leaf datasets
:param str url: URL for the current catalog
:param str xml_content: XML Body returned from HTTP Request
'''
try:
tree = etree.XML(xml_content)
... | def _build_catalog(self, url, xml_content):
'''
Recursive function to perform the DFS and yield the leaf datasets
:param str url: URL for the current catalog
:param str xml_content: XML Body returned from HTTP Request
'''
try:
tree = etree.XML(xml_content)
... | [
"Recursive",
"function",
"to",
"perform",
"the",
"DFS",
"and",
"yield",
"the",
"leaf",
"datasets",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"current",
"catalog",
":",
"param",
"str",
"xml_content",
":",
"XML",
"Body",
"returned",
"from",
"HTTP... | ioos/thredds_crawler | python | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L223-L247 | [
"def",
"_build_catalog",
"(",
"self",
",",
"url",
",",
"xml_content",
")",
":",
"try",
":",
"tree",
"=",
"etree",
".",
"XML",
"(",
"xml_content",
")",
"except",
"BaseException",
":",
"return",
"# Get a list of URLs",
"references",
"=",
"self",
".",
"_compile... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 |
train | Finder.find_module | Find a loader for module or package `fqname`.
This method will be called with the fully qualified name
of the module. If the finder is installed on `sys.meta_path`,
it will receive a second argument, which is `None` for
a top-level module, or `package.__path__` for submodules
or sub... | impala/__init__.py | def find_module(fdr, fqname, path = None):
'''Find a loader for module or package `fqname`.
This method will be called with the fully qualified name
of the module. If the finder is installed on `sys.meta_path`,
it will receive a second argument, which is `None` for
a top-level module, ... | def find_module(fdr, fqname, path = None):
'''Find a loader for module or package `fqname`.
This method will be called with the fully qualified name
of the module. If the finder is installed on `sys.meta_path`,
it will receive a second argument, which is `None` for
a top-level module, ... | [
"Find",
"a",
"loader",
"for",
"module",
"or",
"package",
"fqname",
"."
] | roman-neuhauser/py-impala | python | https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L60-L80 | [
"def",
"find_module",
"(",
"fdr",
",",
"fqname",
",",
"path",
"=",
"None",
")",
":",
"if",
"fqname",
"in",
"fdr",
".",
"aliases",
":",
"return",
"Loader",
"(",
"fqname",
",",
"fdr",
".",
"aliases",
"[",
"fqname",
"]",
")",
"return",
"None"
] | 8a22def2744460d20c620beb24c00332e77125d5 |
train | Loader.load_module | Load `fqname` from under `ldr.fspath`.
The `fqname` argument is the fully qualified module name,
eg. "spam.eggs.ham". As explained above, when ::
finder.find_module("spam.eggs.ham")
is called, "spam.eggs" has already been imported and added
to `sys.modules`. However, the `find_... | impala/__init__.py | def load_module(ldr, fqname):
'''Load `fqname` from under `ldr.fspath`.
The `fqname` argument is the fully qualified module name,
eg. "spam.eggs.ham". As explained above, when ::
finder.find_module("spam.eggs.ham")
is called, "spam.eggs" has already been imported and added
t... | def load_module(ldr, fqname):
'''Load `fqname` from under `ldr.fspath`.
The `fqname` argument is the fully qualified module name,
eg. "spam.eggs.ham". As explained above, when ::
finder.find_module("spam.eggs.ham")
is called, "spam.eggs" has already been imported and added
t... | [
"Load",
"fqname",
"from",
"under",
"ldr",
".",
"fspath",
"."
] | roman-neuhauser/py-impala | python | https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L119-L216 | [
"def",
"load_module",
"(",
"ldr",
",",
"fqname",
")",
":",
"scope",
"=",
"ldr",
".",
"scope",
".",
"split",
"(",
"'.'",
")",
"modpath",
"=",
"fqname",
".",
"split",
"(",
"'.'",
")",
"if",
"scope",
"!=",
"modpath",
"[",
"0",
":",
"len",
"(",
"scop... | 8a22def2744460d20c620beb24c00332e77125d5 |
train | zthread_fork | Create an attached thread. An attached thread gets a ctx and a PAIR
pipe back to its parent. It must monitor its pipe, and exit if the
pipe becomes unreadable. Returns pipe, or NULL if there was an error. | cifsdk/utils/zhelper.py | def zthread_fork(ctx, func, *args, **kwargs):
"""
Create an attached thread. An attached thread gets a ctx and a PAIR
pipe back to its parent. It must monitor its pipe, and exit if the
pipe becomes unreadable. Returns pipe, or NULL if there was an error.
"""
a = ctx.socket(zmq.PAIR)
a.setsoc... | def zthread_fork(ctx, func, *args, **kwargs):
"""
Create an attached thread. An attached thread gets a ctx and a PAIR
pipe back to its parent. It must monitor its pipe, and exit if the
pipe becomes unreadable. Returns pipe, or NULL if there was an error.
"""
a = ctx.socket(zmq.PAIR)
a.setsoc... | [
"Create",
"an",
"attached",
"thread",
".",
"An",
"attached",
"thread",
"gets",
"a",
"ctx",
"and",
"a",
"PAIR",
"pipe",
"back",
"to",
"its",
"parent",
".",
"It",
"must",
"monitor",
"its",
"pipe",
"and",
"exit",
"if",
"the",
"pipe",
"becomes",
"unreadable"... | csirtgadgets/bearded-avenger-sdk-py | python | https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/utils/zhelper.py#L44-L70 | [
"def",
"zthread_fork",
"(",
"ctx",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"a",
"=",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"PAIR",
")",
"a",
".",
"setsockopt",
"(",
"zmq",
".",
"LINGER",
",",
"0",
")",
"a",
".",
"se... | 2b3e96cb2e7703ee0402811096da8265a740f378 |
train | _remap | Prevent accidental assignment of existing members
Arguments:
object (object): Parent of new attribute
name (str): Name of new attribute
value (object): Value of new attribute
safe (bool): Whether or not to guarantee that
the new attribute was not overwritten.
... | pyblish_nuke/vendor/Qt.py | def _remap(object, name, value, safe=True):
"""Prevent accidental assignment of existing members
Arguments:
object (object): Parent of new attribute
name (str): Name of new attribute
value (object): Value of new attribute
safe (bool): Whether or not to guarantee that
... | def _remap(object, name, value, safe=True):
"""Prevent accidental assignment of existing members
Arguments:
object (object): Parent of new attribute
name (str): Name of new attribute
value (object): Value of new attribute
safe (bool): Whether or not to guarantee that
... | [
"Prevent",
"accidental",
"assignment",
"of",
"existing",
"members"
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L77-L108 | [
"def",
"_remap",
"(",
"object",
",",
"name",
",",
"value",
",",
"safe",
"=",
"True",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"\"QT_TESTING\"",
")",
"is",
"not",
"None",
"and",
"safe",
":",
"# Cannot alter original binding.",
"if",
"hasattr",
"(",
"obje... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | init | Try loading each binding in turn
Please note: the entire Qt module is replaced with this code:
sys.modules["Qt"] = binding()
This means no functions or variables can be called after
this has executed.
For debugging and testing, this module may be accessed
through `Qt.__shim__`. | pyblish_nuke/vendor/Qt.py | def init():
"""Try loading each binding in turn
Please note: the entire Qt module is replaced with this code:
sys.modules["Qt"] = binding()
This means no functions or variables can be called after
this has executed.
For debugging and testing, this module may be accessed
through `Qt.__... | def init():
"""Try loading each binding in turn
Please note: the entire Qt module is replaced with this code:
sys.modules["Qt"] = binding()
This means no functions or variables can be called after
this has executed.
For debugging and testing, this module may be accessed
through `Qt.__... | [
"Try",
"loading",
"each",
"binding",
"in",
"turn"
] | pyblish/pyblish-nuke | python | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L299-L365 | [
"def",
"init",
"(",
")",
":",
"preferred",
"=",
"os",
".",
"getenv",
"(",
"\"QT_PREFERRED_BINDING\"",
")",
"verbose",
"=",
"os",
".",
"getenv",
"(",
"\"QT_VERBOSE\"",
")",
"is",
"not",
"None",
"bindings",
"=",
"(",
"_pyside2",
",",
"_pyqt5",
",",
"_pysid... | 5fbd766774e999e5e3015201094a07a92d800c4f |
train | log_instantiation | Log the instantiation of an object to the given logger.
:LOGGER: A logger to log to. Please see module "logging".
:classname: The name of the class that is being
instantiated.
:args: A dictionary of arguments passed to the instantiation,
which will be logged on debug level.
:forbidden: ... | b2handle/util/logutils.py | def log_instantiation(LOGGER, classname, args, forbidden, with_date=False):
'''
Log the instantiation of an object to the given logger.
:LOGGER: A logger to log to. Please see module "logging".
:classname: The name of the class that is being
instantiated.
:args: A dictionary of arguments pa... | def log_instantiation(LOGGER, classname, args, forbidden, with_date=False):
'''
Log the instantiation of an object to the given logger.
:LOGGER: A logger to log to. Please see module "logging".
:classname: The name of the class that is being
instantiated.
:args: A dictionary of arguments pa... | [
"Log",
"the",
"instantiation",
"of",
"an",
"object",
"to",
"the",
"given",
"logger",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/logutils.py#L31-L58 | [
"def",
"log_instantiation",
"(",
"LOGGER",
",",
"classname",
",",
"args",
",",
"forbidden",
",",
"with_date",
"=",
"False",
")",
":",
"# Info:",
"if",
"with_date",
":",
"LOGGER",
".",
"info",
"(",
"'Instantiating '",
"+",
"classname",
"+",
"' at '",
"+",
"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | filter_params | convert dict value if value is bool type,
False -> "false"
True -> "true" | weibopy/weibo.py | def filter_params(params):
"""
convert dict value if value is bool type,
False -> "false"
True -> "true"
"""
if params is not None:
new_params = copy.deepcopy(params)
new_params = dict((k, v) for k, v in new_params.items() if v is not None)
for key, value in new_params.it... | def filter_params(params):
"""
convert dict value if value is bool type,
False -> "false"
True -> "true"
"""
if params is not None:
new_params = copy.deepcopy(params)
new_params = dict((k, v) for k, v in new_params.items() if v is not None)
for key, value in new_params.it... | [
"convert",
"dict",
"value",
"if",
"value",
"is",
"bool",
"type",
"False",
"-",
">",
"false",
"True",
"-",
">",
"true"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L9-L21 | [
"def",
"filter_params",
"(",
"params",
")",
":",
"if",
"params",
"is",
"not",
"None",
":",
"new_params",
"=",
"copy",
".",
"deepcopy",
"(",
"params",
")",
"new_params",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"new_par... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboClient._handler_response | error code response:
{
"request": "/statuses/home_timeline.json",
"error_code": "20502",
"error": "Need you follow uid."
}
:param response:
:return: | weibopy/weibo.py | def _handler_response(self, response, data=None):
"""
error code response:
{
"request": "/statuses/home_timeline.json",
"error_code": "20502",
"error": "Need you follow uid."
}
:param response:
:return:
"""
if response.s... | def _handler_response(self, response, data=None):
"""
error code response:
{
"request": "/statuses/home_timeline.json",
"error_code": "20502",
"error": "Need you follow uid."
}
:param response:
:return:
"""
if response.s... | [
"error",
"code",
"response",
":",
"{",
"request",
":",
"/",
"statuses",
"/",
"home_timeline",
".",
"json",
"error_code",
":",
"20502",
"error",
":",
"Need",
"you",
"follow",
"uid",
".",
"}",
":",
"param",
"response",
":",
":",
"return",
":"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L37-L64 | [
"def",
"_handler_response",
"(",
"self",
",",
"response",
",",
"data",
"=",
"None",
")",
":",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"data",
"=",
"response",
".",
"json",
"(",
")",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
"... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboClient.get | request weibo api
:param suffix: str,
:param params: dict, url query parameters
:return: | weibopy/weibo.py | def get(self, suffix, params=None):
"""
request weibo api
:param suffix: str,
:param params: dict, url query parameters
:return:
"""
url = self.base + suffix
params = filter_params(params)
response = self.session.get(url=url, params=params)
... | def get(self, suffix, params=None):
"""
request weibo api
:param suffix: str,
:param params: dict, url query parameters
:return:
"""
url = self.base + suffix
params = filter_params(params)
response = self.session.get(url=url, params=params)
... | [
"request",
"weibo",
"api",
":",
"param",
"suffix",
":",
"str",
":",
"param",
"params",
":",
"dict",
"url",
"query",
"parameters",
":",
"return",
":"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L66-L80 | [
"def",
"get",
"(",
"self",
",",
"suffix",
",",
"params",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"base",
"+",
"suffix",
"params",
"=",
"filter_params",
"(",
"params",
")",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
"="... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | WeiboClient.post | :return: | weibopy/weibo.py | def post(self, suffix, params=None, data=None, files=None):
"""
:return:
"""
url = self.base + suffix
params = filter_params(params)
response = self.session.post(url=url, params=params, data=data, files=files)
return self._handler_response(response, data=data) | def post(self, suffix, params=None, data=None, files=None):
"""
:return:
"""
url = self.base + suffix
params = filter_params(params)
response = self.session.post(url=url, params=params, data=data, files=files)
return self._handler_response(response, data=data) | [
":",
"return",
":"
] | nooperpudd/weibopy | python | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/weibo.py#L82-L92 | [
"def",
"post",
"(",
"self",
",",
"suffix",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"files",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"base",
"+",
"suffix",
"params",
"=",
"filter_params",
"(",
"params",
")",
"response",
"=... | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 |
train | Searcher.search_handle | Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`.
... | b2handle/searcher.py | def search_handle(self, **args):
'''
Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, the wrong case will cause a :exc:`~b... | def search_handle(self, **args):
'''
Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, the wrong case will cause a :exc:`~b... | [
"Search",
"for",
"handles",
"containing",
"the",
"specified",
"key",
"with",
"the",
"specified",
"value",
".",
"The",
"search",
"terms",
"are",
"passed",
"on",
"to",
"the",
"reverse",
"lookup",
"servlet",
"as",
"-",
"is",
".",
"The",
"servlet",
"is",
"supp... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L210-L250 | [
"def",
"search_handle",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'search_handle...'",
")",
"if",
"self",
".",
"__has_search_access",
":",
"return",
"self",
".",
"__search_handle",
"(",
"*",
"*",
"args",
")",
"else",
":"... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | Searcher.create_revlookup_query | Create the part of the solr request that comes after the question mark,
e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are
configured, only these are used. If no'allowed search keys are
specified, all key-value pairs are passed on to the reverse lookup
servlet.
:param f... | b2handle/searcher.py | def create_revlookup_query(self, *fulltext_searchterms, **keyvalue_searchterms):
'''
Create the part of the solr request that comes after the question mark,
e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are
configured, only these are used. If no'allowed search keys are
... | def create_revlookup_query(self, *fulltext_searchterms, **keyvalue_searchterms):
'''
Create the part of the solr request that comes after the question mark,
e.g. ?URL=*dkrz*&CHECKSUM=*abc*. If allowed search keys are
configured, only these are used. If no'allowed search keys are
... | [
"Create",
"the",
"part",
"of",
"the",
"solr",
"request",
"that",
"comes",
"after",
"the",
"question",
"mark",
"e",
".",
"g",
".",
"?URL",
"=",
"*",
"dkrz",
"*",
"&CHECKSUM",
"=",
"*",
"abc",
"*",
".",
"If",
"allowed",
"search",
"keys",
"are",
"config... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L340-L402 | [
"def",
"create_revlookup_query",
"(",
"self",
",",
"*",
"fulltext_searchterms",
",",
"*",
"*",
"keyvalue_searchterms",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'create_revlookup_query...'",
")",
"allowed_search_keys",
"=",
"self",
".",
"__allowed_search_keys",
"only_se... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | Searcher.__set_revlookup_auth_string | Creates and sets the authentication string for accessing the reverse
lookup servlet. No return, the string is set as an attribute to
the client instance.
:param username: Username.
:param password: Password. | b2handle/searcher.py | def __set_revlookup_auth_string(self, username, password):
'''
Creates and sets the authentication string for accessing the reverse
lookup servlet. No return, the string is set as an attribute to
the client instance.
:param username: Username.
:param password: Pa... | def __set_revlookup_auth_string(self, username, password):
'''
Creates and sets the authentication string for accessing the reverse
lookup servlet. No return, the string is set as an attribute to
the client instance.
:param username: Username.
:param password: Pa... | [
"Creates",
"and",
"sets",
"the",
"authentication",
"string",
"for",
"accessing",
"the",
"reverse",
"lookup",
"servlet",
".",
"No",
"return",
"the",
"string",
"is",
"set",
"as",
"an",
"attribute",
"to",
"the",
"client",
"instance",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/searcher.py#L404-L414 | [
"def",
"__set_revlookup_auth_string",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"auth",
"=",
"b2handle",
".",
"utilhandle",
".",
"create_authentication_string",
"(",
"username",
",",
"password",
")",
"self",
".",
"__revlookup_auth_string",
"=",
"aut... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | PIDClientCredentials.load_from_JSON | Create a new instance of a PIDClientCredentials with information read
from a local JSON file.
:param json_filename: The path to the json credentials file. The json
file should have the following format:
.. code:: json
{
"handle_s... | b2handle/clientcredentials.py | def load_from_JSON(json_filename):
'''
Create a new instance of a PIDClientCredentials with information read
from a local JSON file.
:param json_filename: The path to the json credentials file. The json
file should have the following format:
.. code:: json
... | def load_from_JSON(json_filename):
'''
Create a new instance of a PIDClientCredentials with information read
from a local JSON file.
:param json_filename: The path to the json credentials file. The json
file should have the following format:
.. code:: json
... | [
"Create",
"a",
"new",
"instance",
"of",
"a",
"PIDClientCredentials",
"with",
"information",
"read",
"from",
"a",
"local",
"JSON",
"file",
"."
] | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/clientcredentials.py#L29-L58 | [
"def",
"load_from_JSON",
"(",
"json_filename",
")",
":",
"try",
":",
"jsonfilecontent",
"=",
"json",
".",
"loads",
"(",
"open",
"(",
"json_filename",
",",
"'r'",
")",
".",
"read",
"(",
")",
")",
"except",
"ValueError",
"as",
"exc",
":",
"raise",
"Credent... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | fixture | Load fixtures using a data migration.
The migration will by default provide a rollback, deleting items by primary
key. This is not always what you want ; you may set reversible=False to
prevent rolling back.
Usage:
import myapp
import anotherapp
operations = [
migrations.RunPytho... | django_migration_fixture/__init__.py | def fixture(app, fixtures, fixtures_dir='fixtures', raise_does_not_exist=False,
reversible=True, models=[]):
"""
Load fixtures using a data migration.
The migration will by default provide a rollback, deleting items by primary
key. This is not always what you want ; you may set reversible=F... | def fixture(app, fixtures, fixtures_dir='fixtures', raise_does_not_exist=False,
reversible=True, models=[]):
"""
Load fixtures using a data migration.
The migration will by default provide a rollback, deleting items by primary
key. This is not always what you want ; you may set reversible=F... | [
"Load",
"fixtures",
"using",
"a",
"data",
"migration",
"."
] | alexhayes/django-migration-fixture | python | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/__init__.py#L37-L124 | [
"def",
"fixture",
"(",
"app",
",",
"fixtures",
",",
"fixtures_dir",
"=",
"'fixtures'",
",",
"raise_does_not_exist",
"=",
"False",
",",
"reversible",
"=",
"True",
",",
"models",
"=",
"[",
"]",
")",
":",
"fixture_path",
"=",
"os",
".",
"path",
".",
"join",... | c0463edc599d96bc6f645084eb50e6e94e1f681a |
train | BitMap.nonzero | Get all non-zero bits | src/bitmap.py | def nonzero(self):
"""
Get all non-zero bits
"""
return [i for i in xrange(self.size()) if self.test(i)] | def nonzero(self):
"""
Get all non-zero bits
"""
return [i for i in xrange(self.size()) if self.test(i)] | [
"Get",
"all",
"non",
"-",
"zero",
"bits"
] | wanji/bitmap | python | https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L95-L99 | [
"def",
"nonzero",
"(",
"self",
")",
":",
"return",
"[",
"i",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"size",
"(",
")",
")",
"if",
"self",
".",
"test",
"(",
"i",
")",
"]"
] | beb750530045e4f7cf665675bfb28f82d6325007 |
train | BitMap.tohexstring | Returns a hexadecimal string | src/bitmap.py | def tohexstring(self):
"""
Returns a hexadecimal string
"""
val = self.tostring()
st = "{0:0x}".format(int(val, 2))
return st.zfill(len(self.bitmap)*2) | def tohexstring(self):
"""
Returns a hexadecimal string
"""
val = self.tostring()
st = "{0:0x}".format(int(val, 2))
return st.zfill(len(self.bitmap)*2) | [
"Returns",
"a",
"hexadecimal",
"string"
] | wanji/bitmap | python | https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L131-L137 | [
"def",
"tohexstring",
"(",
"self",
")",
":",
"val",
"=",
"self",
".",
"tostring",
"(",
")",
"st",
"=",
"\"{0:0x}\"",
".",
"format",
"(",
"int",
"(",
"val",
",",
"2",
")",
")",
"return",
"st",
".",
"zfill",
"(",
"len",
"(",
"self",
".",
"bitmap",
... | beb750530045e4f7cf665675bfb28f82d6325007 |
train | BitMap.fromhexstring | Construct BitMap from hex string | src/bitmap.py | def fromhexstring(cls, hexstring):
"""
Construct BitMap from hex string
"""
bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b")
return cls.fromstring(bitstring) | def fromhexstring(cls, hexstring):
"""
Construct BitMap from hex string
"""
bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b")
return cls.fromstring(bitstring) | [
"Construct",
"BitMap",
"from",
"hex",
"string"
] | wanji/bitmap | python | https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L140-L145 | [
"def",
"fromhexstring",
"(",
"cls",
",",
"hexstring",
")",
":",
"bitstring",
"=",
"format",
"(",
"int",
"(",
"hexstring",
",",
"16",
")",
",",
"\"0\"",
"+",
"str",
"(",
"len",
"(",
"hexstring",
")",
"/",
"4",
")",
"+",
"\"b\"",
")",
"return",
"cls"... | beb750530045e4f7cf665675bfb28f82d6325007 |
train | BitMap.fromstring | Construct BitMap from string | src/bitmap.py | def fromstring(cls, bitstring):
"""
Construct BitMap from string
"""
nbits = len(bitstring)
bm = cls(nbits)
for i in xrange(nbits):
if bitstring[-i-1] == '1':
bm.set(i)
elif bitstring[-i-1] != '0':
raise Exception("I... | def fromstring(cls, bitstring):
"""
Construct BitMap from string
"""
nbits = len(bitstring)
bm = cls(nbits)
for i in xrange(nbits):
if bitstring[-i-1] == '1':
bm.set(i)
elif bitstring[-i-1] != '0':
raise Exception("I... | [
"Construct",
"BitMap",
"from",
"string"
] | wanji/bitmap | python | https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L148-L159 | [
"def",
"fromstring",
"(",
"cls",
",",
"bitstring",
")",
":",
"nbits",
"=",
"len",
"(",
"bitstring",
")",
"bm",
"=",
"cls",
"(",
"nbits",
")",
"for",
"i",
"in",
"xrange",
"(",
"nbits",
")",
":",
"if",
"bitstring",
"[",
"-",
"i",
"-",
"1",
"]",
"... | beb750530045e4f7cf665675bfb28f82d6325007 |
train | get_versions | Get version information or return default if unable to do so. | cifsdk/_version.py | def get_versions():
"""Get version information or return default if unable to do so."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
#... | def get_versions():
"""Get version information or return default if unable to do so."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
#... | [
"Get",
"version",
"information",
"or",
"return",
"default",
"if",
"unable",
"to",
"do",
"so",
"."
] | csirtgadgets/bearded-avenger-sdk-py | python | https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/_version.py#L442-L495 | [
"def",
"get_versions",
"(",
")",
":",
"# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have",
"# __file__, we can work backwards from there to the root. Some",
"# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which",
"# case we can only use expanded keywords.... | 2b3e96cb2e7703ee0402811096da8265a740f378 |
train | get_valid_https_verify | Get a value that can be the boolean representation of a string
or a boolean itself and returns It as a boolean.
If this is not the case, It returns a string.
:value: The HTTPS_verify input value. A string can be passed as a path
to a CA_BUNDLE certificate
:returns: True, False or a string. | b2handle/util/utilconfig.py | def get_valid_https_verify(value):
'''
Get a value that can be the boolean representation of a string
or a boolean itself and returns It as a boolean.
If this is not the case, It returns a string.
:value: The HTTPS_verify input value. A string can be passed as a path
to a CA_BUNDLE cert... | def get_valid_https_verify(value):
'''
Get a value that can be the boolean representation of a string
or a boolean itself and returns It as a boolean.
If this is not the case, It returns a string.
:value: The HTTPS_verify input value. A string can be passed as a path
to a CA_BUNDLE cert... | [
"Get",
"a",
"value",
"that",
"can",
"be",
"the",
"boolean",
"representation",
"of",
"a",
"string",
"or",
"a",
"boolean",
"itself",
"and",
"returns",
"It",
"as",
"a",
"boolean",
".",
"If",
"this",
"is",
"not",
"the",
"case",
"It",
"returns",
"a",
"strin... | EUDAT-B2SAFE/B2HANDLE | python | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/utilconfig.py#L6-L24 | [
"def",
"get_valid_https_verify",
"(",
"value",
")",
":",
"http_verify_value",
"=",
"value",
"bool_values",
"=",
"{",
"'false'",
":",
"False",
",",
"'true'",
":",
"True",
"}",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"http_verify_value",
"=",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb |
train | RequireJSFilter.setup | Setup filter (only called when filter is actually used). | invenio_assets/filters.py | def setup(self):
"""Setup filter (only called when filter is actually used)."""
super(RequireJSFilter, self).setup()
excluded_files = []
for bundle in self.excluded_bundles:
excluded_files.extend(
map(lambda f: os.path.splitext(f)[0],
bund... | def setup(self):
"""Setup filter (only called when filter is actually used)."""
super(RequireJSFilter, self).setup()
excluded_files = []
for bundle in self.excluded_bundles:
excluded_files.extend(
map(lambda f: os.path.splitext(f)[0],
bund... | [
"Setup",
"filter",
"(",
"only",
"called",
"when",
"filter",
"is",
"actually",
"used",
")",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L45-L59 | [
"def",
"setup",
"(",
"self",
")",
":",
"super",
"(",
"RequireJSFilter",
",",
"self",
")",
".",
"setup",
"(",
")",
"excluded_files",
"=",
"[",
"]",
"for",
"bundle",
"in",
"self",
".",
"excluded_bundles",
":",
"excluded_files",
".",
"extend",
"(",
"map",
... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | CleanCSSFilter.setup | Initialize filter just before it will be used. | invenio_assets/filters.py | def setup(self):
"""Initialize filter just before it will be used."""
super(CleanCSSFilter, self).setup()
self.root = current_app.config.get('COLLECT_STATIC_ROOT') | def setup(self):
"""Initialize filter just before it will be used."""
super(CleanCSSFilter, self).setup()
self.root = current_app.config.get('COLLECT_STATIC_ROOT') | [
"Initialize",
"filter",
"just",
"before",
"it",
"will",
"be",
"used",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L71-L74 | [
"def",
"setup",
"(",
"self",
")",
":",
"super",
"(",
"CleanCSSFilter",
",",
"self",
")",
".",
"setup",
"(",
")",
"self",
".",
"root",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'COLLECT_STATIC_ROOT'",
")"
] | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | CleanCSSFilter.rebase_opt | Determine which option name to use. | invenio_assets/filters.py | def rebase_opt(self):
"""Determine which option name to use."""
if not hasattr(self, '_rebase_opt'):
# out = b"MAJOR.MINOR.REVISION" // b"3.4.19" or b"4.0.0"
out, err = Popen(
['cleancss', '--version'], stdout=PIPE).communicate()
ver = int(out[:out.ind... | def rebase_opt(self):
"""Determine which option name to use."""
if not hasattr(self, '_rebase_opt'):
# out = b"MAJOR.MINOR.REVISION" // b"3.4.19" or b"4.0.0"
out, err = Popen(
['cleancss', '--version'], stdout=PIPE).communicate()
ver = int(out[:out.ind... | [
"Determine",
"which",
"option",
"name",
"to",
"use",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L77-L85 | [
"def",
"rebase_opt",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_rebase_opt'",
")",
":",
"# out = b\"MAJOR.MINOR.REVISION\" // b\"3.4.19\" or b\"4.0.0\"",
"out",
",",
"err",
"=",
"Popen",
"(",
"[",
"'cleancss'",
",",
"'--version'",
"]",
"... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | CleanCSSFilter.input | Input filtering. | invenio_assets/filters.py | def input(self, _in, out, **kw):
"""Input filtering."""
args = [self.binary or 'cleancss'] + self.rebase_opt
if self.extra_args:
args.extend(self.extra_args)
self.subprocess(args, out, _in) | def input(self, _in, out, **kw):
"""Input filtering."""
args = [self.binary or 'cleancss'] + self.rebase_opt
if self.extra_args:
args.extend(self.extra_args)
self.subprocess(args, out, _in) | [
"Input",
"filtering",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L87-L92 | [
"def",
"input",
"(",
"self",
",",
"_in",
",",
"out",
",",
"*",
"*",
"kw",
")",
":",
"args",
"=",
"[",
"self",
".",
"binary",
"or",
"'cleancss'",
"]",
"+",
"self",
".",
"rebase_opt",
"if",
"self",
".",
"extra_args",
":",
"args",
".",
"extend",
"("... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | AngularGettextFilter.output | Wrap translation in Angular module. | invenio_assets/filters.py | def output(self, _in, out, **kwargs):
"""Wrap translation in Angular module."""
out.write(
'angular.module("{0}", ["gettext"]).run('
'["gettextCatalog", function (gettextCatalog) {{'.format(
self.catalog_name
)
)
out.write(_in.read())
... | def output(self, _in, out, **kwargs):
"""Wrap translation in Angular module."""
out.write(
'angular.module("{0}", ["gettext"]).run('
'["gettextCatalog", function (gettextCatalog) {{'.format(
self.catalog_name
)
)
out.write(_in.read())
... | [
"Wrap",
"translation",
"in",
"Angular",
"module",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L110-L119 | [
"def",
"output",
"(",
"self",
",",
"_in",
",",
"out",
",",
"*",
"*",
"kwargs",
")",
":",
"out",
".",
"write",
"(",
"'angular.module(\"{0}\", [\"gettext\"]).run('",
"'[\"gettextCatalog\", function (gettextCatalog) {{'",
".",
"format",
"(",
"self",
".",
"catalog_name"... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | AngularGettextFilter.input | Process individual translation file. | invenio_assets/filters.py | def input(self, _in, out, **kwargs):
"""Process individual translation file."""
language_code = _re_language_code.search(_in.read()).group(
'language_code'
)
_in.seek(0) # move at the begining after matching the language
catalog = read_po(_in)
out.write('gett... | def input(self, _in, out, **kwargs):
"""Process individual translation file."""
language_code = _re_language_code.search(_in.read()).group(
'language_code'
)
_in.seek(0) # move at the begining after matching the language
catalog = read_po(_in)
out.write('gett... | [
"Process",
"individual",
"translation",
"file",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L121-L133 | [
"def",
"input",
"(",
"self",
",",
"_in",
",",
"out",
",",
"*",
"*",
"kwargs",
")",
":",
"language_code",
"=",
"_re_language_code",
".",
"search",
"(",
"_in",
".",
"read",
"(",
")",
")",
".",
"group",
"(",
"'language_code'",
")",
"_in",
".",
"seek",
... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | BasicAuthMechanism.get_user_and_check_auth | Check the combination username/password that is valid on the
database. | dci/auth_mechanism.py | def get_user_and_check_auth(self, username, password):
"""Check the combination username/password that is valid on the
database.
"""
constraint = sql.or_(
models.USERS.c.name == username,
models.USERS.c.email == username
)
user = self.identity_fro... | def get_user_and_check_auth(self, username, password):
"""Check the combination username/password that is valid on the
database.
"""
constraint = sql.or_(
models.USERS.c.name == username,
models.USERS.c.email == username
)
user = self.identity_fro... | [
"Check",
"the",
"combination",
"username",
"/",
"password",
"that",
"is",
"valid",
"on",
"the",
"database",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/auth_mechanism.py#L135-L149 | [
"def",
"get_user_and_check_auth",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"constraint",
"=",
"sql",
".",
"or_",
"(",
"models",
".",
"USERS",
".",
"c",
".",
"name",
"==",
"username",
",",
"models",
".",
"USERS",
".",
"c",
".",
"email",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Github.retrieve_info | Query the Github API to retrieve the needed infos. | dci/trackers/github.py | def retrieve_info(self):
"""Query the Github API to retrieve the needed infos."""
path = urlparse(self.url).path
path = path.split('/')[1:]
sanity_filter = re.compile('[\da-z-_]+', re.IGNORECASE)
self.product = sanity_filter.match(path[0]).group(0)
self.component = sani... | def retrieve_info(self):
"""Query the Github API to retrieve the needed infos."""
path = urlparse(self.url).path
path = path.split('/')[1:]
sanity_filter = re.compile('[\da-z-_]+', re.IGNORECASE)
self.product = sanity_filter.match(path[0]).group(0)
self.component = sani... | [
"Query",
"the",
"Github",
"API",
"to",
"retrieve",
"the",
"needed",
"infos",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/github.py#L32-L62 | [
"def",
"retrieve_info",
"(",
"self",
")",
":",
"path",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
".",
"path",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"[",
"1",
":",
"]",
"sanity_filter",
"=",
"re",
".",
"compile",
"(",
"'[\\da-z-_]... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Step.disk_cache | Cache the return value in the correct cache directory. Set 'method' to
false for static methods. | sets/core/step.py | def disk_cache(cls, basename, function, *args, method=True, **kwargs):
"""
Cache the return value in the correct cache directory. Set 'method' to
false for static methods.
"""
@utility.disk_cache(basename, cls.directory(), method=method)
def wrapper(*args, **kwargs):
... | def disk_cache(cls, basename, function, *args, method=True, **kwargs):
"""
Cache the return value in the correct cache directory. Set 'method' to
false for static methods.
"""
@utility.disk_cache(basename, cls.directory(), method=method)
def wrapper(*args, **kwargs):
... | [
"Cache",
"the",
"return",
"value",
"in",
"the",
"correct",
"cache",
"directory",
".",
"Set",
"method",
"to",
"false",
"for",
"static",
"methods",
"."
] | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L12-L21 | [
"def",
"disk_cache",
"(",
"cls",
",",
"basename",
",",
"function",
",",
"*",
"args",
",",
"method",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"@",
"utility",
".",
"disk_cache",
"(",
"basename",
",",
"cls",
".",
"directory",
"(",
")",
",",
"me... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.