repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
opennode/waldur-core | waldur_core/logging/views.py | AlertViewSet.create | def create(self, request, *args, **kwargs):
"""
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: jav... | python | def create(self, request, *args, **kwargs):
"""
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: jav... | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"AlertViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and
alert_type already exists - it will be updated. Only users with staff privileges can create alerts.
Request example:
.. code-block:: javascript
POST /api/alerts/
Accept: appli... | [
"Run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"*",
"to",
"create",
"or",
"update",
"alert",
".",
"If",
"alert",
"with",
"posted",
"scope",
"and",
"alert_type",
"already",
"exists",
"-",
"it",
"will",
"be",
"updated",
".",
... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L232-L254 | train |
opennode/waldur-core | waldur_core/logging/views.py | AlertViewSet.close | def close(self, request, *args, **kwargs):
"""
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts.
"""
if not request.user.is_staff:
raise PermissionDenied()
alert = s... | python | def close(self, request, *args, **kwargs):
"""
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts.
"""
if not request.user.is_staff:
raise PermissionDenied()
alert = s... | [
"def",
"close",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_staff",
":",
"raise",
"PermissionDenied",
"(",
")",
"alert",
"=",
"self",
".",
"get_object",
"(",
")",
"... | To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required.
Only users with staff privileges can close alerts. | [
"To",
"close",
"alert",
"-",
"run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"<alert_uuid",
">",
"/",
"close",
"/",
"*",
".",
"No",
"data",
"is",
"required",
".",
"Only",
"users",
"with",
"staff",
"privileges",
"can",
"clos... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L257-L267 | train |
opennode/waldur-core | waldur_core/logging/views.py | AlertViewSet.acknowledge | def acknowledge(self, request, *args, **kwargs):
"""
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 4... | python | def acknowledge(self, request, *args, **kwargs):
"""
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 4... | [
"def",
"acknowledge",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"alert",
"=",
"self",
".",
"get_object",
"(",
")",
"if",
"not",
"alert",
".",
"acknowledged",
":",
"alert",
".",
"acknowledge",
"(",
")",
"return"... | To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required.
All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint
will return error with code 409(conflict). | [
"To",
"acknowledge",
"alert",
"-",
"run",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"<alert_uuid",
">",
"/",
"acknowledge",
"/",
"*",
".",
"No",
"payload",
"is",
"required",
".",
"All",
"users",
"that",
"can",
"see",
"alerts",... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L270-L281 | train |
opennode/waldur-core | waldur_core/logging/views.py | AlertViewSet.stats | def stats(self, request, *args, **kwargs):
"""
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
... | python | def stats(self, request, *args, **kwargs):
"""
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
... | [
"def",
"stats",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"self",
".",
"filter_queryset",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"alerts_severities_count",
"=",
"queryset",
".",
"values",... | To get count of alerts per severities - run **GET** request against */api/alerts/stats/*.
This endpoint supports all filters that are available for alerts list (*/api/alerts/*).
Response example:
.. code-block:: javascript
{
"debug": 2,
"error": 1,
... | [
"To",
"get",
"count",
"of",
"alerts",
"per",
"severities",
"-",
"run",
"**",
"GET",
"**",
"request",
"against",
"*",
"/",
"api",
"/",
"alerts",
"/",
"stats",
"/",
"*",
".",
"This",
"endpoint",
"supports",
"all",
"filters",
"that",
"are",
"available",
"... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L298-L325 | train |
opennode/waldur-core | waldur_core/logging/views.py | WebHookViewSet.create | def create(self, request, *args, **kwargs):
"""
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.... | python | def create(self, request, *args, **kwargs):
"""
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.... | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"WebHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-web/ HTTP/1.1
Content-Type: application/json
Accept:... | [
"To",
"create",
"new",
"web",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"web",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups",
... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L356-L401 | train |
opennode/waldur-core | waldur_core/logging/views.py | EmailHookViewSet.create | def create(self, request, *args, **kwargs):
"""
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ H... | python | def create(self, request, *args, **kwargs):
"""
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ H... | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"EmailHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-email/ HTTP/1.1
Content-Type: application/json
A... | [
"To",
"create",
"new",
"email",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"email",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups"... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L409-L438 | train |
opennode/waldur-core | waldur_core/logging/views.py | PushHookViewSet.create | def create(self, request, *args, **kwargs):
"""
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP... | python | def create(self, request, *args, **kwargs):
"""
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP... | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"PushHookViewSet",
",",
"self",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user.
You should specify list of event_types or event_groups.
Example of a request:
.. code-block:: http
POST /api/hooks-push/ HTTP/1.1
Content-Type: application/json
Acce... | [
"To",
"create",
"new",
"push",
"hook",
"issue",
"**",
"POST",
"**",
"against",
"*",
"/",
"api",
"/",
"hooks",
"-",
"push",
"/",
"*",
"as",
"an",
"authenticated",
"user",
".",
"You",
"should",
"specify",
"list",
"of",
"event_types",
"or",
"event_groups",
... | d6c17a9592bb6c49c33567542eef8d099605a46a | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L446-L475 | train |
alexras/pylsdj | pylsdj/instruments.py | Instruments.import_from_file | def import_from_file(self, index, filename):
"""Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param i... | python | def import_from_file(self, index, filename):
"""Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param i... | [
"def",
"import_from_file",
"(",
"self",
",",
"index",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"fp",
":",
"self",
".",
"_import_from_struct",
"(",
"index",
",",
"json",
".",
"load",
"(",
"fp",
")",
")"
] | Import this instrument's settings from the given file. Will
automatically add the instrument's synth and table to the song's
synths and tables if needed.
Note that this may invalidate existing instrument accessor objects.
:param index: the index into which to import
:param fil... | [
"Import",
"this",
"instrument",
"s",
"settings",
"from",
"the",
"given",
"file",
".",
"Will",
"automatically",
"add",
"the",
"instrument",
"s",
"synth",
"and",
"table",
"to",
"the",
"song",
"s",
"synths",
"and",
"tables",
"if",
"needed",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instruments.py#L63-L80 | train |
alexras/pylsdj | pylsdj/project.py | load_lsdsng | def load_lsdsng(filename):
"""Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# Load preamble data so that we know the name and version of the song
with open(filename, 'rb') as fp:
preamble_data = b... | python | def load_lsdsng(filename):
"""Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# Load preamble data so that we know the name and version of the song
with open(filename, 'rb') as fp:
preamble_data = b... | [
"def",
"load_lsdsng",
"(",
"filename",
")",
":",
"# Load preamble data so that we know the name and version of the song",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"preamble_data",
"=",
"bread",
".",
"parse",
"(",
"fp",
",",
"spec",
".",
... | Load a Project from a ``.lsdsng`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project` | [
"Load",
"a",
"Project",
"from",
"a",
".",
"lsdsng",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L10-L52 | train |
alexras/pylsdj | pylsdj/project.py | load_srm | def load_srm(filename):
"""Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# .srm files are just decompressed projects without headers
# In order to determine the file's size in compressed blocks, we have to... | python | def load_srm(filename):
"""Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project`
"""
# .srm files are just decompressed projects without headers
# In order to determine the file's size in compressed blocks, we have to... | [
"def",
"load_srm",
"(",
"filename",
")",
":",
"# .srm files are just decompressed projects without headers",
"# In order to determine the file's size in compressed blocks, we have to",
"# compress it first",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"r... | Load a Project from an ``.srm`` file.
:param filename: the name of the file from which to load
:rtype: :py:class:`pylsdj.Project` | [
"Load",
"a",
"Project",
"from",
"an",
".",
"srm",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L55-L82 | train |
alexras/pylsdj | pylsdj/project.py | Project.song | def song(self):
"""the song associated with the project"""
if self._song is None:
self._song = Song(self._song_data)
return self._song | python | def song(self):
"""the song associated with the project"""
if self._song is None:
self._song = Song(self._song_data)
return self._song | [
"def",
"song",
"(",
"self",
")",
":",
"if",
"self",
".",
"_song",
"is",
"None",
":",
"self",
".",
"_song",
"=",
"Song",
"(",
"self",
".",
"_song_data",
")",
"return",
"self",
".",
"_song"
] | the song associated with the project | [
"the",
"song",
"associated",
"with",
"the",
"project"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L119-L124 | train |
alexras/pylsdj | pylsdj/project.py | Project.save | def save(self, filename):
"""Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead
"""
with open(filename, 'wb') as fp:
writer = BlockWriter()
factor... | python | def save(self, filename):
"""Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead
"""
with open(filename, 'wb') as fp:
writer = BlockWriter()
factor... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"writer",
"=",
"BlockWriter",
"(",
")",
"factory",
"=",
"BlockFactory",
"(",
")",
"preamble_dummy_bytes",
"=",
"bytearray",
"(",
... | Save a project in .lsdsng format to the target file.
:param filename: the name of the file to which to save
:deprecated: use ``save_lsdsng(filename)`` instead | [
"Save",
"a",
"project",
"in",
".",
"lsdsng",
"format",
"to",
"the",
"target",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L133-L159 | train |
alexras/pylsdj | pylsdj/project.py | Project.save_srm | def save_srm(self, filename):
"""Save a project in .srm format to the target file.
:param filename: the name of the file to which to save
"""
with open(filename, 'wb') as fp:
raw_data = bread.write(self._song_data, spec.song)
fp.write(raw_data) | python | def save_srm(self, filename):
"""Save a project in .srm format to the target file.
:param filename: the name of the file to which to save
"""
with open(filename, 'wb') as fp:
raw_data = bread.write(self._song_data, spec.song)
fp.write(raw_data) | [
"def",
"save_srm",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"raw_data",
"=",
"bread",
".",
"write",
"(",
"self",
".",
"_song_data",
",",
"spec",
".",
"song",
")",
"fp",
".",
"write"... | Save a project in .srm format to the target file.
:param filename: the name of the file to which to save | [
"Save",
"a",
"project",
"in",
".",
"srm",
"format",
"to",
"the",
"target",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/project.py#L168-L175 | train |
alexras/pylsdj | pylsdj/synth.py | Synth.phase_type | def phase_type(self, value):
'''compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"``'''
self._params.phase_type = value
self._overwrite_lock.disable() | python | def phase_type(self, value):
'''compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"``'''
self._params.phase_type = value
self._overwrite_lock.disable() | [
"def",
"phase_type",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_params",
".",
"phase_type",
"=",
"value",
"self",
".",
"_overwrite_lock",
".",
"disable",
"(",
")"
] | compresses the waveform horizontally; one of
``"normal"``, ``"resync"``, ``"resync2"`` | [
"compresses",
"the",
"waveform",
"horizontally",
";",
"one",
"of",
"normal",
"resync",
"resync2"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/synth.py#L186-L190 | train |
alexras/pylsdj | pylsdj/savfile.py | SAVFile.project_list | def project_list(self):
"""The list of :py:class:`pylsdj.Project` s that the
.sav file contains"""
return [(i, self.projects[i]) for i in sorted(self.projects.keys())] | python | def project_list(self):
"""The list of :py:class:`pylsdj.Project` s that the
.sav file contains"""
return [(i, self.projects[i]) for i in sorted(self.projects.keys())] | [
"def",
"project_list",
"(",
"self",
")",
":",
"return",
"[",
"(",
"i",
",",
"self",
".",
"projects",
"[",
"i",
"]",
")",
"for",
"i",
"in",
"sorted",
"(",
"self",
".",
"projects",
".",
"keys",
"(",
")",
")",
"]"
] | The list of :py:class:`pylsdj.Project` s that the
.sav file contains | [
"The",
"list",
"of",
":",
"py",
":",
"class",
":",
"pylsdj",
".",
"Project",
"s",
"that",
"the",
".",
"sav",
"file",
"contains"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L207-L210 | train |
alexras/pylsdj | pylsdj/savfile.py | SAVFile.save | def save(self, filename, callback=_noop_callback):
"""Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function
"""
with open(filename, 'wb') as fp:
... | python | def save(self, filename, callback=_noop_callback):
"""Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function
"""
with open(filename, 'wb') as fp:
... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"callback",
"=",
"_noop_callback",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"self",
".",
"_save",
"(",
"fp",
",",
"callback",
")"
] | Save this file.
:param filename: the file to which to save the .sav file
:type filename: str
:param callback: a progress callback function
:type callback: function | [
"Save",
"this",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/savfile.py#L312-L321 | train |
alexras/pylsdj | pylsdj/filepack.py | split | def split(compressed_data, segment_size, block_factory):
"""Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of bl... | python | def split(compressed_data, segment_size, block_factory):
"""Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of bl... | [
"def",
"split",
"(",
"compressed_data",
",",
"segment_size",
",",
"block_factory",
")",
":",
"# Split compressed data into blocks",
"segments",
"=",
"[",
"]",
"current_segment_start",
"=",
"0",
"index",
"=",
"0",
"data_size",
"=",
"len",
"(",
"compressed_data",
")... | Splits compressed data into blocks.
:param compressed_data: the compressed data to split
:param segment_size: the size of a block in bytes
:param block_factory: a BlockFactory used to construct the blocks
:rtype: a list of block IDs of blocks that the block factory created while
splitting | [
"Splits",
"compressed",
"data",
"into",
"blocks",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L46-L138 | train |
alexras/pylsdj | pylsdj/filepack.py | renumber_block_keys | def renumber_block_keys(blocks):
"""Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map
"""
# There is an implicit block switch to the 0th block at the start of the
# file
... | python | def renumber_block_keys(blocks):
"""Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map
"""
# There is an implicit block switch to the 0th block at the start of the
# file
... | [
"def",
"renumber_block_keys",
"(",
"blocks",
")",
":",
"# There is an implicit block switch to the 0th block at the start of the",
"# file",
"byte_switch_keys",
"=",
"[",
"0",
"]",
"block_keys",
"=",
"list",
"(",
"blocks",
".",
"keys",
"(",
")",
")",
"# Scan the blocks,... | Renumber a block map's indices so that tehy match the blocks' block
switch statements.
:param blocks a block map to renumber
:rtype: a renumbered copy of the block map | [
"Renumber",
"a",
"block",
"map",
"s",
"indices",
"so",
"that",
"tehy",
"match",
"the",
"blocks",
"block",
"switch",
"statements",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L141-L201 | train |
alexras/pylsdj | pylsdj/filepack.py | merge | def merge(blocks):
"""Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes
"""
current_block = blocks[sorted(blocks.keys())[0]]
compressed_data = []
eof = False
while not eof:
data_size_to_appe... | python | def merge(blocks):
"""Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes
"""
current_block = blocks[sorted(blocks.keys())[0]]
compressed_data = []
eof = False
while not eof:
data_size_to_appe... | [
"def",
"merge",
"(",
"blocks",
")",
":",
"current_block",
"=",
"blocks",
"[",
"sorted",
"(",
"blocks",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"]",
"compressed_data",
"=",
"[",
"]",
"eof",
"=",
"False",
"while",
"not",
"eof",
":",
"data_size_to_ap... | Merge the given blocks into a contiguous block of compressed data.
:param blocks: the list of blocks
:rtype: a list of compressed bytes | [
"Merge",
"the",
"given",
"blocks",
"into",
"a",
"contiguous",
"block",
"of",
"compressed",
"data",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L204-L259 | train |
alexras/pylsdj | pylsdj/filepack.py | pad | def pad(segment, size):
"""Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment
"""
for i in range(size - len(segment)):
segment.append(0)
assert len(segment) == size | python | def pad(segment, size):
"""Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment
"""
for i in range(size - len(segment)):
segment.append(0)
assert len(segment) == size | [
"def",
"pad",
"(",
"segment",
",",
"size",
")",
":",
"for",
"i",
"in",
"range",
"(",
"size",
"-",
"len",
"(",
"segment",
")",
")",
":",
"segment",
".",
"append",
"(",
"0",
")",
"assert",
"len",
"(",
"segment",
")",
"==",
"size"
] | Add zeroes to a segment until it reaches a certain size.
:param segment: the segment to pad
:param size: the size to which to pad the segment | [
"Add",
"zeroes",
"to",
"a",
"segment",
"until",
"it",
"reaches",
"a",
"certain",
"size",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L276-L285 | train |
alexras/pylsdj | pylsdj/filepack.py | decompress | def decompress(compressed_data):
"""Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes"""
raw_data = []
index = 0
while index < len(compressed_data):
curren... | python | def decompress(compressed_data):
"""Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes"""
raw_data = []
index = 0
while index < len(compressed_data):
curren... | [
"def",
"decompress",
"(",
"compressed_data",
")",
":",
"raw_data",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"len",
"(",
"compressed_data",
")",
":",
"current",
"=",
"compressed_data",
"[",
"index",
"]",
"index",
"+=",
"1",
"if",
"current"... | Decompress data that has been compressed by the filepack algorithm.
:param compressed_data: an array of compressed data bytes to decompress
:rtype: an array of decompressed bytes | [
"Decompress",
"data",
"that",
"has",
"been",
"compressed",
"by",
"the",
"filepack",
"algorithm",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L288-L338 | train |
alexras/pylsdj | pylsdj/filepack.py | compress | def compress(raw_data):
"""Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes
"""
raw_data = bytearray(raw_data)
compressed_data = []
data_size = len(raw_data)
index = 0
next_bytes = [-1, -1, ... | python | def compress(raw_data):
"""Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes
"""
raw_data = bytearray(raw_data)
compressed_data = []
data_size = len(raw_data)
index = 0
next_bytes = [-1, -1, ... | [
"def",
"compress",
"(",
"raw_data",
")",
":",
"raw_data",
"=",
"bytearray",
"(",
"raw_data",
")",
"compressed_data",
"=",
"[",
"]",
"data_size",
"=",
"len",
"(",
"raw_data",
")",
"index",
"=",
"0",
"next_bytes",
"=",
"[",
"-",
"1",
",",
"-",
"1",
","... | Compress raw bytes with the filepack algorithm.
:param raw_data: an array of raw data bytes to compress
:rtype: a list of compressed bytes | [
"Compress",
"raw",
"bytes",
"with",
"the",
"filepack",
"algorithm",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/filepack.py#L341-L433 | train |
alexras/pylsdj | pylsdj/utils.py | name_without_zeroes | def name_without_zeroes(name):
"""
Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes
"""
first_zero = name.find(b'\0')
if first_zero == -1:
return name
else:
return str... | python | def name_without_zeroes(name):
"""
Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes
"""
first_zero = name.find(b'\0')
if first_zero == -1:
return name
else:
return str... | [
"def",
"name_without_zeroes",
"(",
"name",
")",
":",
"first_zero",
"=",
"name",
".",
"find",
"(",
"b'\\0'",
")",
"if",
"first_zero",
"==",
"-",
"1",
":",
"return",
"name",
"else",
":",
"return",
"str",
"(",
"name",
"[",
":",
"first_zero",
"]",
")"
] | Return a human-readable name without LSDJ's trailing zeroes.
:param name: the name from which to strip zeroes
:rtype: the name, without trailing zeroes | [
"Return",
"a",
"human",
"-",
"readable",
"name",
"without",
"LSDJ",
"s",
"trailing",
"zeroes",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/utils.py#L32-L44 | train |
alexras/pylsdj | pylsdj/instrument.py | Instrument.name | def name(self):
"""the instrument's name (5 characters, zero-padded)"""
instr_name = self.song.song_data.instrument_names[self.index]
if type(instr_name) == bytes:
instr_name = instr_name.decode('utf-8')
return instr_name | python | def name(self):
"""the instrument's name (5 characters, zero-padded)"""
instr_name = self.song.song_data.instrument_names[self.index]
if type(instr_name) == bytes:
instr_name = instr_name.decode('utf-8')
return instr_name | [
"def",
"name",
"(",
"self",
")",
":",
"instr_name",
"=",
"self",
".",
"song",
".",
"song_data",
".",
"instrument_names",
"[",
"self",
".",
"index",
"]",
"if",
"type",
"(",
"instr_name",
")",
"==",
"bytes",
":",
"instr_name",
"=",
"instr_name",
".",
"de... | the instrument's name (5 characters, zero-padded) | [
"the",
"instrument",
"s",
"name",
"(",
"5",
"characters",
"zero",
"-",
"padded",
")"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L21-L28 | train |
alexras/pylsdj | pylsdj/instrument.py | Instrument.table | 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.... | python | 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",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"data",
",",
"'table_on'",
")",
"and",
"self",
".",
"data",
".",
"table_on",
":",
"assert_index_sane",
"(",
"self",
".",
"data",
".",
"table",
",",
"len",
"(",
"self",
".",
"... | a ```pylsdj.Table``` referencing the instrument's table, or None
if the instrument doesn't have a table | [
"a",
"pylsdj",
".",
"Table",
"referencing",
"the",
"instrument",
"s",
"table",
"or",
"None",
"if",
"the",
"instrument",
"doesn",
"t",
"have",
"a",
"table"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L47-L52 | train |
alexras/pylsdj | pylsdj/instrument.py | Instrument.import_lsdinst | 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) | python | 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",
")",
":",
"self",
".",
"name",
"=",
"struct_data",
"[",
"'name'",
"]",
"self",
".",
"automate",
"=",
"struct_data",
"[",
"'data'",
"]",
"[",
"'automate'",
"]",
"self",
".",
"pan",
"=",
"struct_dat... | import from an lsdinst struct | [
"import",
"from",
"an",
"lsdinst",
"struct"
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L79-L86 | train |
alexras/pylsdj | pylsdj/instrument.py | Instrument.export_to_file | 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) | python | 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",
")",
":",
"instr_json",
"=",
"self",
".",
"export_struct",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fp",
":",
"json",
".",
"dump",
"(",
"instr_json",
",",
"fp",
",",
"in... | Export this instrument's settings to a file.
:param filename: the name of the file | [
"Export",
"this",
"instrument",
"s",
"settings",
"to",
"a",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/instrument.py#L88-L96 | train |
alexras/pylsdj | pylsdj/kits.py | KitSample.write_wav | 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 ... | python | 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",
")",
":",
"wave_output",
"=",
"None",
"try",
":",
"wave_output",
"=",
"wave",
".",
"open",
"(",
"filename",
",",
"'w'",
")",
"wave_output",
".",
"setparams",
"(",
"WAVE_PARAMS",
")",
"frames",
"=",
"bytea... | Write this sample to a WAV file.
:param filename: the file to which to write | [
"Write",
"this",
"sample",
"to",
"a",
"WAV",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L229-L246 | train |
alexras/pylsdj | pylsdj/kits.py | KitSample.read_wav | 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... | python | 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",
")",
":",
"wave_input",
"=",
"None",
"try",
":",
"wave_input",
"=",
"wave",
".",
"open",
"(",
"filename",
",",
"'r'",
")",
"wave_frames",
"=",
"bytearray",
"(",
"wave_input",
".",
"readframes",
"(",
"wave_... | Read sample data for this sample from a WAV file.
:param filename: the file from which to read | [
"Read",
"sample",
"data",
"for",
"this",
"sample",
"from",
"a",
"WAV",
"file",
"."
] | 1c45a7919dd324e941f76b315558b9647892e4d5 | https://github.com/alexras/pylsdj/blob/1c45a7919dd324e941f76b315558b9647892e4d5/pylsdj/kits.py#L248-L264 | train |
thusoy/headsup | headsup.py | get_device_address | 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... | python | 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",
")",
":",
"if",
"device",
"is",
"None",
":",
"return",
"None",
"command",
"=",
"[",
"'ip'",
",",
"'route'",
",",
"'list'",
",",
"'dev'",
",",
"device",
"]",
"ip_routes",
"=",
"subprocess",
".",
"check_output",
... | find the local ip address on the given device | [
"find",
"the",
"local",
"ip",
"address",
"on",
"the",
"given",
"device"
] | 165a63cc6c987f664f2efd901d483ca07b7bc898 | https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L68-L80 | train |
thusoy/headsup | headsup.py | get_default_net_device | 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 | python | 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",
"(",
")",
":",
"with",
"open",
"(",
"'/proc/net/route'",
")",
"as",
"fh",
":",
"for",
"line",
"in",
"fh",
":",
"iface",
",",
"dest",
",",
"_",
"=",
"line",
".",
"split",
"(",
"None",
",",
"2",
")",
"if",
"dest",
"==... | Find the device where the default route is. | [
"Find",
"the",
"device",
"where",
"the",
"default",
"route",
"is",
"."
] | 165a63cc6c987f664f2efd901d483ca07b7bc898 | https://github.com/thusoy/headsup/blob/165a63cc6c987f664f2efd901d483ca07b7bc898/headsup.py#L83-L90 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/util/argsutils.py | add_missing_optional_args_with_value_none | 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 ... | python | 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",
")",
":",
"for",
"name",
"in",
"optional_args",
":",
"if",
"not",
"name",
"in",
"args",
".",
"keys",
"(",
")",
":",
"args",
"[",
"name",
"]",
"=",
"None",
"return",
"arg... | 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:... | [
"Adds",
"key",
"-",
"value",
"pairs",
"to",
"the",
"passed",
"dictionary",
"so",
"that",
"afterwards",
"the",
"dictionary",
"can",
"be",
"used",
"without",
"needing",
"to",
"check",
"for",
"KeyErrors",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L3-L21 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/util/argsutils.py | check_presence_of_mandatory_args | 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... | python | 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",
")",
":",
"missing_args",
"=",
"[",
"]",
"for",
"name",
"in",
"mandatory_args",
":",
"if",
"name",
"not",
"in",
"args",
".",
"keys",
"(",
")",
":",
"missing_args",
".",
"append",
... | 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... | [
"Checks",
"whether",
"all",
"mandatory",
"arguments",
"are",
"passed",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/argsutils.py#L24-L47 | train |
ipazc/pyzip | pyzip/__init__.py | PyZip.size | 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) | python | 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",
")",
":",
"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 | [
"Retrieves",
"the",
"size",
"in",
"bytes",
"of",
"this",
"ZIP",
"content",
".",
":",
"return",
":",
"Size",
"of",
"the",
"zip",
"content",
"in",
"bytes"
] | 8680775ddba079a9a04ef3904252a9afb62cb7cc | https://github.com/ipazc/pyzip/blob/8680775ddba079a9a04ef3904252a9afb62cb7cc/pyzip/__init__.py#L171-L179 | train |
alexhayes/django-migration-fixture | django_migration_fixture/management/commands/create_initial_data_fixtures.py | Command.monkey_patch_migration_template | 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... | python | 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",
")",
":",
"self",
".",
"_MIGRATION_TEMPLATE",
"=",
"writer",
".",
"MIGRATION_TEMPLATE",
"module_split",
"=",
"app",
".",
"module",
".",
"__name__",
".",
"split",
"(",
"'.'",
... | 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. | [
"Monkey",
"patch",
"the",
"django",
".",
"db",
".",
"migrations",
".",
"writer",
".",
"MIGRATION_TEMPLATE"
] | c0463edc599d96bc6f645084eb50e6e94e1f681a | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L38-L69 | train |
alexhayes/django-migration-fixture | django_migration_fixture/management/commands/create_initial_data_fixtures.py | Command.migration_exists | 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')):
... | python | 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",
")",
":",
"base_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fixture_path",
")",
"# Loop through all migrations",
"for",
"migration_path",
"in",
"glob",
".",
"glob",
"(",
"os",
... | Return true if it looks like a migration already exists. | [
"Return",
"true",
"if",
"it",
"looks",
"like",
"a",
"migration",
"already",
"exists",
"."
] | c0463edc599d96bc6f645084eb50e6e94e1f681a | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L77-L86 | train |
alexhayes/django-migration-fixture | django_migration_fixture/management/commands/create_initial_data_fixtures.py | Command.create_migration | 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... | python | 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",
")",
":",
"self",
".",
"monkey_patch_migration_template",
"(",
"app",
",",
"fixture_path",
")",
"out",
"=",
"StringIO",
"(",
")",
"management",
".",
"call_command",
"(",
"'makemigrations'",... | Create a data migration for app that uses fixture_path. | [
"Create",
"a",
"data",
"migration",
"for",
"app",
"that",
"uses",
"fixture_path",
"."
] | c0463edc599d96bc6f645084eb50e6e94e1f681a | https://github.com/alexhayes/django-migration-fixture/blob/c0463edc599d96bc6f645084eb50e6e94e1f681a/django_migration_fixture/management/commands/create_initial_data_fixtures.py#L88-L99 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.instantiate_for_read_and_search | 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... | python | 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",
")",
":",
"if",
"handle_server_url",
"is",
"None",
"and",
"'reverselookup_baseuri'",
"not",
"in",
"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.handle.net' is used).
:param reverselookup_username: The username to authenticate at the
reverse lookup servlet.
... | [
"Initialize",
"client",
"with",
"read",
"access",
"and",
"with",
"search",
"function",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L183-L209 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.instantiate_with_username_and_password | 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... | python | 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",
")",
":",
"inst",
"=",
"EUDATHandleClient",
"(",
"handle_server_url",
",",
"username",
"=",
"username",
",",
"password",
"=",
"pas... | 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... | [
"Initialize",
"client",
"against",
"an",
"HSv8",
"instance",
"with",
"full",
"read",
"/",
"write",
"access",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L212-L233 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.instantiate_with_credentials | 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... | python | 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",
")",
":",
"key_value_pairs",
"=",
"credentials",
".",
"get_all_args",
"(",
")",
"if",
"config",
"is",
"not",
"None",
":",
"key_value_pairs",
".",
"update",
"(",
"*",
"*",
"co... | 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... | [
"Initialize",
"the",
"client",
"against",
"an",
"HSv8",
"instance",
"with",
"full",
"read",
"/",
"write",
"access",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L236-L255 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.retrieve_handle_record_json | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'retrieve_handle_record_json...'",
")",
"utilhandle",
".",
"check_handle_syntax",
"(",
"handle",
")",
"response",
"=",
"self",
".",
"__send_handle_get_request",
... | 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... | [
"Retrieve",
"a",
"handle",
"record",
"from",
"the",
"Handle",
"server",
"as",
"a",
"complete",
"nested",
"dict",
"(",
"including",
"index",
"ttl",
"timestamp",
"...",
")",
"for",
"later",
"use",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L259-L299 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.retrieve_handle_record | 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.
... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'retrieve_handle_record...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
"handle",
"... | 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... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L302-L329 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.get_value_from_handle | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'get_value_from_handle...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
... | 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:... | [
"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",
... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L331-L363 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.is_10320LOC_empty | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'is_10320LOC_empty...'",
")",
"handlerecord_json",
"=",
"self",
".",
"__get_handle_record_if_necessary",
"(",
"handle",
",",
"han... | 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 ... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L365-L402 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.generate_and_register_handle | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'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... | [
"Register",
"a",
"new",
"Handle",
"with",
"a",
"unique",
"random",
"name",
"(",
"random",
"UUID",
")",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L445-L471 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.modify_handle_value | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'modify_handle_value...'",
")",
"# Read handle record:",
"handlerecord_json... | 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... | [
"Modify",
"entries",
"(",
"key",
"-",
"value",
"-",
"pairs",
")",
"in",
"a",
"handle",
"record",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"yet",
"it",
"is",
"created",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L473-L587 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.delete_handle_value | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'delete_handle_value...'",
")",
"# read handle record:",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L589-L648 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'delete_handle...'",
")",
"utilhandle",
".",
"check_handle_syntax",
"(",
"handle",
")",
"# Safety check. In old epic client, the method could be used for",
"... | 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... | [
"Delete",
"the",
"handle",
"and",
"its",
"handle",
"record",
".",
"If",
"the",
"Handle",
"is",
"not",
"found",
"an",
"Exception",
"is",
"raised",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L650-L684 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.exchange_additional_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.
... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'exchange_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"han... | 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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L686-L729 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.add_additional_URL | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'add_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
... | 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... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L731-L781 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.remove_additional_URL | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'remove_additional_URL...'",
")",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"if",
"handlerecord_js... | 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... | [
"Remove",
"a",
"URL",
"from",
"the",
"handle",
"record",
"s",
"10320",
"/",
"LOC",
"entry",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L783-L825 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.register_handle | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L827-L930 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.search_handle | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'search_handle...'",
")",
"list_of_handles",
"=",
"self",
".",
"__searcher",
".",
"search_ha... | 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`.
... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L934-L973 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.generate_PID_name | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'generate_PID_name...'",
")",
"randomuuid",
"=",
"uuid",
".",
"uuid4",
"(",
")",
"if",
"prefix",
"is",
"not",
"None",
":",
"return",
"prefix",
"+... | 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... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L975-L993 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.get_handlerecord_indices_for_key | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'get_handlerecord_indices_for_key...'",
")",
"indices",
"=",
"[",
"]",
"for",
"entry",
"in",
"list_of_entries",
":",
"if",
"entry",
... | 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... | [
"Finds",
"the",
"Handle",
"entry",
"indices",
"of",
"all",
"entries",
"that",
"have",
"a",
"specific",
"type",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L997-L1019 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__send_handle_delete_request | 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... | python | 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",
")",
":",
"resp",
"=",
"self",
".",
"__handlesystemconnector",
".",
"send_handle_delete_request",
"(",
"handle",
"=",
"handle",
",",
"indice... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1023-L1040 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__send_handle_put_request | 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... | python | 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",
")",
":",
"resp",
",",
"payload",
"=",
"self",
".",
"__handlesystemconnector",
".",
... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1042-L1066 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__send_handle_get_request | 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... | python | 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",
")",
":",
"resp",
"=",
"self",
".",
"__handlesystemconnector",
".",
"send_handle_get_request",
"(",
"handle",
",",
"indices",
")",
"return",
"resp"
] | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1068-L1082 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__get_handle_record_if_necessary | 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... | python | 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",
")",
":",
"if",
"handlerecord_json",
"is",
"None",
":",
"handlerecord_json",
"=",
"self",
".",
"retrieve_handle_record_json",
"(",
"handle",
")",
"else",
":",
"if",
"h... | Returns the handle record if it is None or if its handle is not the
same as the specified handle. | [
"Returns",
"the",
"handle",
"record",
"if",
"it",
"is",
"None",
"or",
"if",
"its",
"handle",
"is",
"not",
"the",
"same",
"as",
"the",
"specified",
"handle",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1084-L1095 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__make_another_index | 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... | python | 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",
")",
":",
"start",
"=",
"2",
"# reserved indices:",
"reserved_for_url",
"=",
"set",
"(",
"[",
"1",
"]",
")",
"reserved_for_admin",
"=... | 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 ... | [
"Find",
"an",
"index",
"not",
"yet",
"used",
"in",
"the",
"handle",
"record",
"and",
"not",
"reserved",
"for",
"any",
"(",
"other",
")",
"special",
"type",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1097-L1136 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__create_entry | 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 '... | python | 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",
")",
":",
"if",
"entrytype",
"==",
"'HS_ADMIN'",
":",
"op",
"=",
"'creating HS_ADMIN entry'",
"msg",
"=",
"'This method can not create HS_ADMIN entries.'",
... | 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... | [
"Create",
"an",
"entry",
"of",
"any",
"type",
"except",
"HS_ADMIN",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1138-L1165 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__create_admin_entry | 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... | python | 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",
")",
":",
"# If the handle owner is specified, use it. Otherwise, use 200:0.NA/prefix",
"# With the prefix taken from the handle that is bei... | 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... | [
"Create",
"an",
"entry",
"of",
"type",
"HS_ADMIN",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1167-L1206 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__get_python_indices_for_key | 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... | python | 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",
")",
":",
"indices",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"list_of_entries",
")",
")",
":",
"if",
"list_of_entries",
"[",
"i",
"]",
"[",
"'type... | 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... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1208-L1224 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__exchange_URL_in_13020loc | 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... | python | 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",
")",
":",
"# Find existing 10320/LOC entries",
"python_indices",
"=",
"self",
".",
"__get_python_indices_for_key",
"(",
"'10320/LOC'",
",",
"list_of_en... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1226-L1271 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__remove_URL_from_10320LOC | 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... | python | 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",
")",
":",
"# Find existing 10320/LOC entries",
"python_indices",
"=",
"self",
".",
"__get_python_indices_for_key",
"(",
"'10320/LOC'",
",",
"list_of_entries",
")",
"num_... | 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... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1273-L1327 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__add_URL_to_10320LOC | 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).
... | python | 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",
")",
":",
"# Find existing 10320/LOC entry or create new",
"indices"... | 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.
... | [
"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... | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1329-L1417 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | EUDATHandleClient.__set_or_adapt_10320LOC_attributes | 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... | python | 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",
")",
":",
"if",
"weight",
"is",
"not",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'__set_or_ad... | 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 ... | [
"Adds",
"or",
"updates",
"attributes",
"of",
"a",
"<location",
">",
"element",
".",
"Existing",
"attributes",
"are",
"not",
"removed!"
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1419-L1451 | train |
nooperpudd/weibopy | weibopy/auth.py | WeiboOauth2.authorize_url | 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") == ... | python | 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",
")",
":",
"if",
"self",
".",
"oauth2_params",
"and",
"self",
".",
"oauth2_params",
".",
"get",
"(",
"\"display\"",
")",
"==",
"\"mobile\"",
":",
"auth_url",
"=",
"self",
".",
"mobile_url",
"+",
"\"authorize\"",
"else",
... | authorization url
request weibo authorization url
:return:
code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。
state string 如果传递参数,会回传该参数 | [
"authorization",
"url",
"request",
"weibo",
"authorization",
"url",
":",
"return",
":",
"code",
"string",
"用于第二步调用oauth2",
"/",
"access_token接口,获取授权后的access",
"token。",
"state",
"string",
"如果传递参数,会回传该参数"
] | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L68-L90 | train |
nooperpudd/weibopy | weibopy/auth.py | WeiboOauth2.request | 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... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"site_url",
"+",
"suffix",
"response",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
",",
"url",
",",
"data",
"=",
"data",
")... | :param method: str, http method ["GET","POST","PUT"]
:param suffix: the url suffix
:param data:
:return: | [
":",
"param",
"method",
":",
"str",
"http",
"method",
"[",
"GET",
"POST",
"PUT",
"]",
":",
"param",
"suffix",
":",
"the",
"url",
"suffix",
":",
"param",
"data",
":",
":",
"return",
":"
] | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L92-L123 | train |
nooperpudd/weibopy | weibopy/auth.py | WeiboOauth2.auth_access | def auth_access(self, auth_code):
"""
verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值... | python | def auth_access(self, auth_code):
"""
verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值... | [
"def",
"auth_access",
"(",
"self",
",",
"auth_code",
")",
":",
"data",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"a... | verify the fist authorization response url code
response data
返回值字段 字段类型 字段说明
access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,
第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值里的UID
字段来做登录识别。
... | [
"verify",
"the",
"fist",
"authorization",
"response",
"url",
"code"
] | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L125-L166 | train |
nooperpudd/weibopy | weibopy/auth.py | WeiboOauth2.revoke_auth_access | def revoke_auth_access(self, access_token):
"""
授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return... | python | def revoke_auth_access(self, access_token):
"""
授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return... | [
"def",
"revoke_auth_access",
"(",
"self",
",",
"access_token",
")",
":",
"result",
"=",
"self",
".",
"request",
"(",
"\"post\"",
",",
"\"revokeoauth2\"",
",",
"data",
"=",
"{",
"\"access_token\"",
":",
"access_token",
"}",
")",
"return",
"bool",
"(",
"result... | 授权回收接口,帮助开发者主动取消用户的授权。
应用下线时,清空所有用户的授权
应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权
开发者调试应用,需要反复调试授权功能
应用内实现类似登出微博帐号的功能
并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间
:param access_token:
:return: bool | [
"授权回收接口,帮助开发者主动取消用户的授权。"
] | 61f3fb0502c1f07a591388aaa7526e74c63eaeb1 | https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L168-L183 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.__set_basic_auth_string | 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... | python | 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",
")",
":",
"auth",
"=",
"b2handle",
".",
"utilhandle",
".",
"create_authentication_string",
"(",
"username",
",",
"password",
")",
"self",
".",
"__basic_authentication_string",
"=",
"a... | 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 ... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L236-L247 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.send_handle_get_request | 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... | python | 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",
")",
":",
"# Assemble required info:",
"url",
"=",
"self",
".",
"make_handle_URL",
"(",
"handle",
",",
"indices",
")",
"LOGGER",
".",
"debug",
"(",
"'GET Request to '",
... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L252-L292 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.send_handle_put_request | 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... | python | 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",
")",
":",
"# Check if we have write access at all:",
"if",
"not",
"self",
".",
"__has_write_access",
":",
"raise",
"HandleAuthenticationError",
"(",
"msg",
"=",
"self",
".",
"__no_auth_message",
"... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L301-L356 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.send_handle_delete_request | 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... | python | 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",
")",
":",
"# Check if we have write access at all:",
"if",
"not",
"self",
".",
"__has_write_access",
":",
"raise",
"HandleAuthenticationError",
"(",
"msg",
"=",
"self",
".",
"__no_auth_message",
... | 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... | [
"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",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L384-L445 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.check_if_username_exists | 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`... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'check_if_username_exists...'",
")",
"_",
",",
"handle",
"=",
"b2handle",
".",
"utilhandle",
".",
"remove_index_from_handle",
"(",
"username",
")",
"resp",
"... | 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... | [
"Check",
"if",
"the",
"username",
"handles",
"exists",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L447-L482 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.__get_headers | 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', ... | python | 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",
")",
":",
"header",
"=",
"{",
"}",
"accept",
"=",
"'application/json'",
"content_type",
"=",
"'application/json'",
"if",
"action",
"is",
"'GET'",
":",
"header",
"[",
"'Accept'",
"]",
"=",
"accept",
"elif",
... | 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... | [
"Create",
"HTTP",
"headers",
"for",
"different",
"HTTP",
"requests",
".",
"Content",
"-",
"type",
"and",
"Accept",
"are",
"application",
"/",
"json",
"as",
"the",
"library",
"is",
"interacting",
"with",
"a",
"REST",
"API",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L484-L517 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handlesystemconnector.py | HandleSystemConnector.make_handle_URL | 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... | python | 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",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'make_handle_URL...'",
")",
"separator",
"=",
"'?'",
"if",
"other_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.
... | [
"Create",
"the",
"URL",
"for",
"a",
"HTTP",
"request",
"(",
"URL",
"+",
"query",
"string",
")",
"to",
"request",
"a",
"specific",
"handle",
"from",
"the",
"Handle",
"Server",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handlesystemconnector.py#L519-L561 | train |
fdChasm/txCarbonClient | src/txCarbonClient/carbon_client_service.py | CarbonClientService.publish_metric | 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... | python | 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",
")",
":",
"if",
"epoch_seconds",
"is",
"None",
":",
"epoch_seconds",
"=",
"self",
".",
"_reactor",
".",
"seconds",
"(",
")",
"self",
".",
"_cl... | 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 | [
"Record",
"a",
"single",
"hit",
"on",
"a",
"given",
"metric",
"."
] | c342eff1957d281cba3c83fc578f08c4bf9fcd03 | https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L30-L44 | train |
fdChasm/txCarbonClient | src/txCarbonClient/carbon_client_service.py | CarbonClientService.register_repeating_metric | 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.
... | python | 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",
")",
":",
"l",
"=",
"task",
".",
"LoopingCall",
"(",
"self",
".",
"_publish_repeating_metric",
",",
"metric_name",
",",
"getter",
")",
"repeating_metric_handle",
... | 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... | [
"Record",
"hits",
"to",
"a",
"metric",
"at",
"a",
"specified",
"interval",
"."
] | c342eff1957d281cba3c83fc578f08c4bf9fcd03 | https://github.com/fdChasm/txCarbonClient/blob/c342eff1957d281cba3c83fc578f08c4bf9fcd03/src/txCarbonClient/carbon_client_service.py#L46-L63 | train |
pyblish/pyblish-nuke | pyblish_nuke/lib.py | setup | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_has_been_setup",
":",
"teardown",
"(",
")",
"register_plugins",
"(",
")",
"register_host",
"(",
")",
"if",
"menu",
":",
"... | 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... | [
"Setup",
"integration"
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L28-L52 | train |
pyblish/pyblish-nuke | pyblish_nuke/lib.py | show | 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... | python | 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",
"(",
")",
":",
"parent",
"=",
"None",
"current",
"=",
"QtWidgets",
".",
"QApplication",
".",
"activeWindow",
"(",
")",
"while",
"current",
":",
"parent",
"=",
"current",
"current",
"=",
"parent",
".",
"parent",
"(",
")",
"window",
"=",
"... | Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user. | [
"Try",
"showing",
"the",
"most",
"desirable",
"GUI"
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L55-L72 | train |
pyblish/pyblish-nuke | pyblish_nuke/lib.py | _nuke_set_zero_margins | 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... | python | 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",
")",
":",
"parentApp",
"=",
"QtWidgets",
".",
"QApplication",
".",
"allWidgets",
"(",
")",
"parentWidgetList",
"=",
"[",
"]",
"for",
"parent",
"in",
"parentApp",
":",
"for",
"child",
"in",
"parent",
".",
... | Remove Nuke margins when docked UI
.. _More info:
https://gist.github.com/maty974/4739917 | [
"Remove",
"Nuke",
"margins",
"when",
"docked",
"UI",
"..",
"_More",
"info",
":",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"maty974",
"/",
"4739917"
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L303-L325 | train |
pyblish/pyblish-nuke | pyblish_nuke/lib.py | dock | 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
... | python | 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",
")",
":",
"# 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... | Expecting a window to parent into a Nuke panel, that is dockable. | [
"Expecting",
"a",
"window",
"to",
"parent",
"into",
"a",
"Nuke",
"panel",
"that",
"is",
"dockable",
"."
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/lib.py#L335-L379 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/utilhandle.py | remove_index_from_handle | 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:
... | python | 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",
")",
":",
"split",
"=",
"handle_with_index",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"split",
")",
"==",
"2",
":",
"split",
"[",
"0",
"]",
"=",
"int",
"(",
"split",
"[",
"0",
"]",
... | 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. | [
"Returns",
"index",
"and",
"handle",
"separately",
"in",
"a",
"tuple",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L14-L33 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/utilhandle.py | check_handle_syntax | 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.... | python | 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",
")",
":",
"expected",
"=",
"'prefix/suffix'",
"try",
":",
"arr",
"=",
"string",
".",
"split",
"(",
"'/'",
")",
"except",
"AttributeError",
":",
"raise",
"handleexceptions",
".",
"HandleSyntaxError",
"(",
"msg",
"=",... | 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. | [
"Checks",
"the",
"syntax",
"of",
"a",
"handle",
"without",
"an",
"index",
"(",
"are",
"prefix",
"and",
"suffix",
"there",
"are",
"there",
"too",
"many",
"slashes?",
")",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L35-L68 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/utilhandle.py | create_authentication_string | 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... | python | 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",
")",
":",
"username_utf8",
"=",
"username",
".",
"encode",
"(",
"'utf-8'",
")",
"userpw_utf8",
"=",
"password",
".",
"encode",
"(",
"'utf-8'",
")",
"username_perc",
"=",
"quote",
"(",
"us... | Creates an authentication string from the username and password.
:username: Username.
:password: Password.
:return: The encoded string. | [
"Creates",
"an",
"authentication",
"string",
"from",
"the",
"username",
"and",
"password",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L102-L118 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/utilhandle.py | make_request_log_message | 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... | python | 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",
")",
":",
"mandatory_args",
"=",
"[",
"'op'",
",",
"'handle'",
",",
"'url'",
",",
"'headers'",
",",
"'verify'",
",",
"'resp'",
"]",
"optional_args",
"=",
"[",
"'payload'",
"]",
"util",
".",
"check_p... | 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 ... | [
"Creates",
"a",
"string",
"containing",
"all",
"relevant",
"information",
"about",
"a",
"request",
"made",
"to",
"the",
"Handle",
"System",
"for",
"logging",
"purposes",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/utilhandle.py#L120-L154 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | request_xml | 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... | python | 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",
")",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"auth",
",",
"verify",
"=",
"False",
")",
"return",
"r",
".",
"text",
".",
"encode",
"(",
"'utf-8'",... | Returns an etree.XMLRoot object loaded from the url
:param str url: URL for the resource to load as an XML | [
"Returns",
"an",
"etree",
".",
"XMLRoot",
"object",
"loaded",
"from",
"the",
"url",
":",
"param",
"str",
"url",
":",
"URL",
"for",
"the",
"resource",
"to",
"load",
"as",
"an",
"XML"
] | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L35-L45 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | Crawl._get_catalog_url | 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... | python | 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",
")",
":",
"u",
"=",
"urlparse",
".",
"urlsplit",
"(",
"url",
")",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"u",
".",
"path",
")",
"if",
"ext",
"==",
"\".html\"",
":",
"u... | Returns the appropriate catalog URL by replacing html with xml in some
cases
:param str url: URL to the catalog | [
"Returns",
"the",
"appropriate",
"catalog",
"URL",
"by",
"replacing",
"html",
"with",
"xml",
"in",
"some",
"cases",
":",
"param",
"str",
"url",
":",
"URL",
"to",
"the",
"catalog"
] | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L133-L144 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | Crawl._yield_leaves | 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... | python | 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",
")",
":",
"for",
"leaf",
"in",
"tree",
".",
"findall",
"(",
"'.//{%s}dataset[@urlPath]'",
"%",
"INV_NS",
")",
":",
"# Subset by the skips",
"name",
"=",
"leaf",
".",
"get",
"(",
"\"name\"",
")",... | 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 | [
"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... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L146-L185 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | Crawl._compile_references | 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... | python | 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",
")",
":",
"references",
"=",
"[",
"]",
"for",
"ref",
"in",
"tree",
".",
"findall",
"(",
"'.//{%s}catalogRef'",
"%",
"INV_NS",
")",
":",
"# Check skips",
"title",
"=",
"ref",
".",
"get",
... | 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 | [
"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... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L187-L201 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | Crawl._run | 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... | python | 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",
")",
":",
"if",
"url",
"in",
"self",
".",
"visited",
":",
"logger",
".",
"debug",
"(",
"\"Skipping %s (already crawled)\"",
"%",
"url",
")",
"return",
"self",
".",
"visited",
".",
"append",
"(",
"url... | 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 | [
"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",... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L203-L221 | train |
ioos/thredds_crawler | thredds_crawler/crawl.py | Crawl._build_catalog | 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)
... | python | 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",
")",
":",
"try",
":",
"tree",
"=",
"etree",
".",
"XML",
"(",
"xml_content",
")",
"except",
"BaseException",
":",
"return",
"# Get a list of URLs",
"references",
"=",
"self",
".",
"_compile... | 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 | [
"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... | fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6 | https://github.com/ioos/thredds_crawler/blob/fb29ea2fb8d079cacc6c09f79245e8f54f77c6a6/thredds_crawler/crawl.py#L223-L247 | train |
roman-neuhauser/py-impala | impala/__init__.py | Finder.find_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, ... | python | 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",
")",
":",
"if",
"fqname",
"in",
"fdr",
".",
"aliases",
":",
"return",
"Loader",
"(",
"fqname",
",",
"fdr",
".",
"aliases",
"[",
"fqname",
"]",
")",
"return",
"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, or `package.__path__` for submodules
or sub... | [
"Find",
"a",
"loader",
"for",
"module",
"or",
"package",
"fqname",
"."
] | 8a22def2744460d20c620beb24c00332e77125d5 | https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L60-L80 | train |
roman-neuhauser/py-impala | impala/__init__.py | Loader.load_module | 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... | python | 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",
")",
":",
"scope",
"=",
"ldr",
".",
"scope",
".",
"split",
"(",
"'.'",
")",
"modpath",
"=",
"fqname",
".",
"split",
"(",
"'.'",
")",
"if",
"scope",
"!=",
"modpath",
"[",
"0",
":",
"len",
"(",
"scop... | 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_... | [
"Load",
"fqname",
"from",
"under",
"ldr",
".",
"fspath",
"."
] | 8a22def2744460d20c620beb24c00332e77125d5 | https://github.com/roman-neuhauser/py-impala/blob/8a22def2744460d20c620beb24c00332e77125d5/impala/__init__.py#L119-L216 | train |
csirtgadgets/bearded-avenger-sdk-py | cifsdk/utils/zhelper.py | zthread_fork | 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... | python | 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",
")",
":",
"a",
"=",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"PAIR",
")",
"a",
".",
"setsockopt",
"(",
"zmq",
".",
"LINGER",
",",
"0",
")",
"a",
".",
"se... | 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. | [
"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"... | 2b3e96cb2e7703ee0402811096da8265a740f378 | https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/utils/zhelper.py#L44-L70 | train |
pyblish/pyblish-nuke | pyblish_nuke/vendor/Qt.py | _remap | 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
... | python | 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",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"\"QT_TESTING\"",
")",
"is",
"not",
"None",
"and",
"safe",
":",
"# Cannot alter original binding.",
"if",
"hasattr",
"(",
"obje... | 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.
... | [
"Prevent",
"accidental",
"assignment",
"of",
"existing",
"members"
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L77-L108 | train |
pyblish/pyblish-nuke | pyblish_nuke/vendor/Qt.py | init | 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.__... | python | 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",
"(",
")",
":",
"preferred",
"=",
"os",
".",
"getenv",
"(",
"\"QT_PREFERRED_BINDING\"",
")",
"verbose",
"=",
"os",
".",
"getenv",
"(",
"\"QT_VERBOSE\"",
")",
"is",
"not",
"None",
"bindings",
"=",
"(",
"_pyside2",
",",
"_pyqt5",
",",
"_pysid... | 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__`. | [
"Try",
"loading",
"each",
"binding",
"in",
"turn"
] | 5fbd766774e999e5e3015201094a07a92d800c4f | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L299-L365 | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/util/logutils.py | log_instantiation | 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... | python | 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",
")",
":",
"# Info:",
"if",
"with_date",
":",
"LOGGER",
".",
"info",
"(",
"'Instantiating '",
"+",
"classname",
"+",
"' at '",
"+",
"... | 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: ... | [
"Log",
"the",
"instantiation",
"of",
"an",
"object",
"to",
"the",
"given",
"logger",
"."
] | a6d216d459644e01fbdfd5b318a535950bc5cdbb | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/util/logutils.py#L31-L58 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.