id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53,000 | marcinmiklitz/pywindow | pywindow/utilities.py | frac2cart_all | def frac2cart_all(frac_coordinates, lattice_array):
"""Convert all fractional coordinates to cartesian."""
coordinates = deepcopy(frac_coordinates)
for coord in range(coordinates.shape[0]):
coordinates[coord] = cartisian_from_fractional(coordinates[coord],
... | python | def frac2cart_all(frac_coordinates, lattice_array):
"""Convert all fractional coordinates to cartesian."""
coordinates = deepcopy(frac_coordinates)
for coord in range(coordinates.shape[0]):
coordinates[coord] = cartisian_from_fractional(coordinates[coord],
... | [
"def",
"frac2cart_all",
"(",
"frac_coordinates",
",",
"lattice_array",
")",
":",
"coordinates",
"=",
"deepcopy",
"(",
"frac_coordinates",
")",
"for",
"coord",
"in",
"range",
"(",
"coordinates",
".",
"shape",
"[",
"0",
"]",
")",
":",
"coordinates",
"[",
"coor... | Convert all fractional coordinates to cartesian. | [
"Convert",
"all",
"fractional",
"coordinates",
"to",
"cartesian",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L768-L774 |
53,001 | marcinmiklitz/pywindow | pywindow/utilities.py | angle_between_vectors | def angle_between_vectors(x, y):
"""Calculate the angle between two vectors x and y."""
first_step = abs(x[0] * y[0] + x[1] * y[1] + x[2] * y[2]) / (
np.sqrt(x[0]**2 + x[1]**2 + x[2]**2) *
np.sqrt(y[0]**2 + y[1]**2 + y[2]**2))
second_step = np.arccos(first_step)
return (second_step) | python | def angle_between_vectors(x, y):
"""Calculate the angle between two vectors x and y."""
first_step = abs(x[0] * y[0] + x[1] * y[1] + x[2] * y[2]) / (
np.sqrt(x[0]**2 + x[1]**2 + x[2]**2) *
np.sqrt(y[0]**2 + y[1]**2 + y[2]**2))
second_step = np.arccos(first_step)
return (second_step) | [
"def",
"angle_between_vectors",
"(",
"x",
",",
"y",
")",
":",
"first_step",
"=",
"abs",
"(",
"x",
"[",
"0",
"]",
"*",
"y",
"[",
"0",
"]",
"+",
"x",
"[",
"1",
"]",
"*",
"y",
"[",
"1",
"]",
"+",
"x",
"[",
"2",
"]",
"*",
"y",
"[",
"2",
"]"... | Calculate the angle between two vectors x and y. | [
"Calculate",
"the",
"angle",
"between",
"two",
"vectors",
"x",
"and",
"y",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L1086-L1092 |
53,002 | marcinmiklitz/pywindow | pywindow/utilities.py | vector_analysis | def vector_analysis(vector, coordinates, elements_vdw, increment=1.0):
"""Analyse a sampling vector's path for window analysis purpose."""
# Calculate number of chunks if vector length is divided by increment.
chunks = int(np.linalg.norm(vector) // increment)
# Create a single chunk.
chunk = vector ... | python | def vector_analysis(vector, coordinates, elements_vdw, increment=1.0):
"""Analyse a sampling vector's path for window analysis purpose."""
# Calculate number of chunks if vector length is divided by increment.
chunks = int(np.linalg.norm(vector) // increment)
# Create a single chunk.
chunk = vector ... | [
"def",
"vector_analysis",
"(",
"vector",
",",
"coordinates",
",",
"elements_vdw",
",",
"increment",
"=",
"1.0",
")",
":",
"# Calculate number of chunks if vector length is divided by increment.",
"chunks",
"=",
"int",
"(",
"np",
".",
"linalg",
".",
"norm",
"(",
"vec... | Analyse a sampling vector's path for window analysis purpose. | [
"Analyse",
"a",
"sampling",
"vector",
"s",
"path",
"for",
"window",
"analysis",
"purpose",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L1095-L1113 |
53,003 | marcinmiklitz/pywindow | pywindow/utilities.py | optimise_xy | def optimise_xy(xy, *args):
"""Return negative pore diameter for x and y coordinates optimisation."""
z, elements, coordinates = args
window_com = np.array([xy[0], xy[1], z])
return -pore_diameter(elements, coordinates, com=window_com)[0] | python | def optimise_xy(xy, *args):
"""Return negative pore diameter for x and y coordinates optimisation."""
z, elements, coordinates = args
window_com = np.array([xy[0], xy[1], z])
return -pore_diameter(elements, coordinates, com=window_com)[0] | [
"def",
"optimise_xy",
"(",
"xy",
",",
"*",
"args",
")",
":",
"z",
",",
"elements",
",",
"coordinates",
"=",
"args",
"window_com",
"=",
"np",
".",
"array",
"(",
"[",
"xy",
"[",
"0",
"]",
",",
"xy",
"[",
"1",
"]",
",",
"z",
"]",
")",
"return",
... | Return negative pore diameter for x and y coordinates optimisation. | [
"Return",
"negative",
"pore",
"diameter",
"for",
"x",
"and",
"y",
"coordinates",
"optimisation",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L1142-L1146 |
53,004 | marcinmiklitz/pywindow | pywindow/utilities.py | optimise_z | def optimise_z(z, *args):
"""Return pore diameter for coordinates optimisation in z direction."""
x, y, elements, coordinates = args
window_com = np.array([x, y, z])
return pore_diameter(elements, coordinates, com=window_com)[0] | python | def optimise_z(z, *args):
"""Return pore diameter for coordinates optimisation in z direction."""
x, y, elements, coordinates = args
window_com = np.array([x, y, z])
return pore_diameter(elements, coordinates, com=window_com)[0] | [
"def",
"optimise_z",
"(",
"z",
",",
"*",
"args",
")",
":",
"x",
",",
"y",
",",
"elements",
",",
"coordinates",
"=",
"args",
"window_com",
"=",
"np",
".",
"array",
"(",
"[",
"x",
",",
"y",
",",
"z",
"]",
")",
"return",
"pore_diameter",
"(",
"eleme... | Return pore diameter for coordinates optimisation in z direction. | [
"Return",
"pore",
"diameter",
"for",
"coordinates",
"optimisation",
"in",
"z",
"direction",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L1149-L1153 |
53,005 | sglyon/distcan | distcan/matrix.py | WishartIWishartParent.rand | def rand(self, n=1):
"""
Generate random samples from the distribution
Parameters
----------
n : int, optional(default=1)
The number of samples to generate
Returns
-------
out : array_like
The generated samples
"""
... | python | def rand(self, n=1):
"""
Generate random samples from the distribution
Parameters
----------
n : int, optional(default=1)
The number of samples to generate
Returns
-------
out : array_like
The generated samples
"""
... | [
"def",
"rand",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"if",
"n",
"==",
"1",
":",
"return",
"self",
".",
"_rand1",
"(",
")",
"else",
":",
"out",
"=",
"np",
".",
"empty",
"(",
"(",
"n",
",",
"self",
".",
"_p",
",",
"self",
".",
"_p",
")... | Generate random samples from the distribution
Parameters
----------
n : int, optional(default=1)
The number of samples to generate
Returns
-------
out : array_like
The generated samples | [
"Generate",
"random",
"samples",
"from",
"the",
"distribution"
] | 7e2a4c810c18e8292fa3c50c2f47347ee2707d58 | https://github.com/sglyon/distcan/blob/7e2a4c810c18e8292fa3c50c2f47347ee2707d58/distcan/matrix.py#L176-L198 |
53,006 | sglyon/distcan | distcan/matrix.py | Wishart._c0 | def _c0(self):
"the logarithm of normalizing constant in pdf"
h_df = self.df / 2
p, S = self._p, self.S
return h_df * (logdet(S) + p * logtwo) + lpgamma(p, h_df) | python | def _c0(self):
"the logarithm of normalizing constant in pdf"
h_df = self.df / 2
p, S = self._p, self.S
return h_df * (logdet(S) + p * logtwo) + lpgamma(p, h_df) | [
"def",
"_c0",
"(",
"self",
")",
":",
"h_df",
"=",
"self",
".",
"df",
"/",
"2",
"p",
",",
"S",
"=",
"self",
".",
"_p",
",",
"self",
".",
"S",
"return",
"h_df",
"*",
"(",
"logdet",
"(",
"S",
")",
"+",
"p",
"*",
"logtwo",
")",
"+",
"lpgamma",
... | the logarithm of normalizing constant in pdf | [
"the",
"logarithm",
"of",
"normalizing",
"constant",
"in",
"pdf"
] | 7e2a4c810c18e8292fa3c50c2f47347ee2707d58 | https://github.com/sglyon/distcan/blob/7e2a4c810c18e8292fa3c50c2f47347ee2707d58/distcan/matrix.py#L228-L233 |
53,007 | sglyon/distcan | distcan/matrix.py | Wishart._genA | def _genA(self):
"""
Generate the matrix A in the Bartlett decomposition
A is a lower triangular matrix, with
A(i, j) ~ sqrt of Chisq(df - i + 1) when i == j
~ Normal() when i > j
"""
p, df = self._p, self.df
A = np... | python | def _genA(self):
"""
Generate the matrix A in the Bartlett decomposition
A is a lower triangular matrix, with
A(i, j) ~ sqrt of Chisq(df - i + 1) when i == j
~ Normal() when i > j
"""
p, df = self._p, self.df
A = np... | [
"def",
"_genA",
"(",
"self",
")",
":",
"p",
",",
"df",
"=",
"self",
".",
"_p",
",",
"self",
".",
"df",
"A",
"=",
"np",
".",
"zeros",
"(",
"(",
"p",
",",
"p",
")",
")",
"for",
"i",
"in",
"range",
"(",
"p",
")",
":",
"A",
"[",
"i",
",",
... | Generate the matrix A in the Bartlett decomposition
A is a lower triangular matrix, with
A(i, j) ~ sqrt of Chisq(df - i + 1) when i == j
~ Normal() when i > j | [
"Generate",
"the",
"matrix",
"A",
"in",
"the",
"Bartlett",
"decomposition"
] | 7e2a4c810c18e8292fa3c50c2f47347ee2707d58 | https://github.com/sglyon/distcan/blob/7e2a4c810c18e8292fa3c50c2f47347ee2707d58/distcan/matrix.py#L235-L254 |
53,008 | sglyon/distcan | distcan/matrix.py | Wishart._rand1 | def _rand1(self):
"generate a single random sample"
Z = _unwhiten_cf(self._S_cf, self._genA())
return Z.dot(Z.T) | python | def _rand1(self):
"generate a single random sample"
Z = _unwhiten_cf(self._S_cf, self._genA())
return Z.dot(Z.T) | [
"def",
"_rand1",
"(",
"self",
")",
":",
"Z",
"=",
"_unwhiten_cf",
"(",
"self",
".",
"_S_cf",
",",
"self",
".",
"_genA",
"(",
")",
")",
"return",
"Z",
".",
"dot",
"(",
"Z",
".",
"T",
")"
] | generate a single random sample | [
"generate",
"a",
"single",
"random",
"sample"
] | 7e2a4c810c18e8292fa3c50c2f47347ee2707d58 | https://github.com/sglyon/distcan/blob/7e2a4c810c18e8292fa3c50c2f47347ee2707d58/distcan/matrix.py#L256-L259 |
53,009 | marcinmiklitz/pywindow | pywindow/io_tools.py | Input.load_file | def load_file(self, filepath):
"""
This function opens any type of a readable file and decompose
the file object into a list, for each line, of lists containing
splitted line strings using space as a spacer.
Parameters
----------
filepath : :class:`str`
... | python | def load_file(self, filepath):
"""
This function opens any type of a readable file and decompose
the file object into a list, for each line, of lists containing
splitted line strings using space as a spacer.
Parameters
----------
filepath : :class:`str`
... | [
"def",
"load_file",
"(",
"self",
",",
"filepath",
")",
":",
"self",
".",
"file_path",
"=",
"filepath",
"_",
",",
"self",
".",
"file_type",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filepath",
")",
"_",
",",
"self",
".",
"file_name",
"=",
"os",
... | This function opens any type of a readable file and decompose
the file object into a list, for each line, of lists containing
splitted line strings using space as a spacer.
Parameters
----------
filepath : :class:`str`
The full path or a relative path to any type of ... | [
"This",
"function",
"opens",
"any",
"type",
"of",
"a",
"readable",
"file",
"and",
"decompose",
"the",
"file",
"object",
"into",
"a",
"list",
"for",
"each",
"line",
"of",
"lists",
"containing",
"splitted",
"line",
"strings",
"using",
"space",
"as",
"a",
"sp... | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/io_tools.py#L45-L73 |
53,010 | marcinmiklitz/pywindow | pywindow/io_tools.py | Output.dump2json | def dump2json(self, obj, filepath, override=False, **kwargs):
"""
Dump a dictionary into a JSON dictionary.
Uses the json.dump() function.
Parameters
----------
obj : :class:`dict`
A dictionary to be dumpped as JSON file.
filepath : :class:`str`
... | python | def dump2json(self, obj, filepath, override=False, **kwargs):
"""
Dump a dictionary into a JSON dictionary.
Uses the json.dump() function.
Parameters
----------
obj : :class:`dict`
A dictionary to be dumpped as JSON file.
filepath : :class:`str`
... | [
"def",
"dump2json",
"(",
"self",
",",
"obj",
",",
"filepath",
",",
"override",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# We make sure that the object passed by the user is a dictionary.",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"pass",
... | Dump a dictionary into a JSON dictionary.
Uses the json.dump() function.
Parameters
----------
obj : :class:`dict`
A dictionary to be dumpped as JSON file.
filepath : :class:`str`
The filepath for the dumped file.
override : :class:`bool`
... | [
"Dump",
"a",
"dictionary",
"into",
"a",
"JSON",
"dictionary",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/io_tools.py#L193-L231 |
53,011 | sacrud/sacrud | sacrud/action.py | CRUD.create | def create(self, data, update=False, **kwargs):
"""
Creates a new object pretreated input data.
.. code-block:: python
DBSession.sacrud(Users).create({'name': 'Vasya', 'sex': 1})
Support JSON:
.. code-block:: python
DBSession.sacrud(Users).create('{"n... | python | def create(self, data, update=False, **kwargs):
"""
Creates a new object pretreated input data.
.. code-block:: python
DBSession.sacrud(Users).create({'name': 'Vasya', 'sex': 1})
Support JSON:
.. code-block:: python
DBSession.sacrud(Users).create('{"n... | [
"def",
"create",
"(",
"self",
",",
"data",
",",
"update",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"unjson",
"(",
"data",
")",
"if",
"update",
"is",
"True",
":",
"obj",
"=",
"get_obj_by_request_data",
"(",
"self",
".",
"session",... | Creates a new object pretreated input data.
.. code-block:: python
DBSession.sacrud(Users).create({'name': 'Vasya', 'sex': 1})
Support JSON:
.. code-block:: python
DBSession.sacrud(Users).create('{"name": "Vasya", "sex": 1}')
For adding multiple data for m2m... | [
"Creates",
"a",
"new",
"object",
"pretreated",
"input",
"data",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/action.py#L38-L67 |
53,012 | sacrud/sacrud | sacrud/action.py | CRUD.read | def read(self, *pk):
"""
Return a list of entries in the table or single
entry if there is an pk.
.. code-block:: python
# All users
DBSession.sacrud(Users).read()
# Composite primary_key
DBSession.sacrud(User2Groups).read({'user_id': 4,... | python | def read(self, *pk):
"""
Return a list of entries in the table or single
entry if there is an pk.
.. code-block:: python
# All users
DBSession.sacrud(Users).read()
# Composite primary_key
DBSession.sacrud(User2Groups).read({'user_id': 4,... | [
"def",
"read",
"(",
"self",
",",
"*",
"pk",
")",
":",
"pk",
"=",
"[",
"unjson",
"(",
"obj",
")",
"for",
"obj",
"in",
"pk",
"]",
"if",
"len",
"(",
"pk",
")",
"==",
"1",
":",
"# like ([1,2,3,4,5], )",
"return",
"get_obj",
"(",
"self",
".",
"session... | Return a list of entries in the table or single
entry if there is an pk.
.. code-block:: python
# All users
DBSession.sacrud(Users).read()
# Composite primary_key
DBSession.sacrud(User2Groups).read({'user_id': 4, 'group_id': 2})
# Multiple ... | [
"Return",
"a",
"list",
"of",
"entries",
"in",
"the",
"table",
"or",
"single",
"entry",
"if",
"there",
"is",
"an",
"pk",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/action.py#L69-L117 |
53,013 | sacrud/sacrud | sacrud/action.py | CRUD._add | def _add(self, obj, data, **kwargs):
""" Update the object directly.
.. code-block:: python
DBSession.sacrud(Users)._add(UserObj, {'name': 'Gennady'})
"""
if isinstance(obj, sqlalchemy.orm.query.Query):
obj = obj.one()
obj = self.preprocessing(obj=obj or... | python | def _add(self, obj, data, **kwargs):
""" Update the object directly.
.. code-block:: python
DBSession.sacrud(Users)._add(UserObj, {'name': 'Gennady'})
"""
if isinstance(obj, sqlalchemy.orm.query.Query):
obj = obj.one()
obj = self.preprocessing(obj=obj or... | [
"def",
"_add",
"(",
"self",
",",
"obj",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"sqlalchemy",
".",
"orm",
".",
"query",
".",
"Query",
")",
":",
"obj",
"=",
"obj",
".",
"one",
"(",
")",
"obj",
"=",
... | Update the object directly.
.. code-block:: python
DBSession.sacrud(Users)._add(UserObj, {'name': 'Gennady'}) | [
"Update",
"the",
"object",
"directly",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/action.py#L175-L192 |
53,014 | sacrud/sacrud | sacrud/action.py | CRUD._delete | def _delete(self, obj, **kwargs):
""" Delete the object directly.
.. code-block:: python
DBSession.sacrud(Users)._delete(UserObj)
If you no needed commit session
.. code-block:: python
DBSession.sacrud(Users, commit=False)._delete(UserObj)
"""
... | python | def _delete(self, obj, **kwargs):
""" Delete the object directly.
.. code-block:: python
DBSession.sacrud(Users)._delete(UserObj)
If you no needed commit session
.. code-block:: python
DBSession.sacrud(Users, commit=False)._delete(UserObj)
"""
... | [
"def",
"_delete",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"sqlalchemy",
".",
"orm",
".",
"query",
".",
"Query",
")",
":",
"obj",
"=",
"obj",
".",
"one",
"(",
")",
"obj",
"=",
"self",
".",... | Delete the object directly.
.. code-block:: python
DBSession.sacrud(Users)._delete(UserObj)
If you no needed commit session
.. code-block:: python
DBSession.sacrud(Users, commit=False)._delete(UserObj) | [
"Delete",
"the",
"object",
"directly",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/action.py#L194-L216 |
53,015 | KujiraProject/Flask-PAM | flask_pam/auth.py | Auth.authenticated | def authenticated(self, user_token, **validation_context):
"""Checks if user is authenticated using token passed in argument
:param user_token: string representing token
:param validation_context: Token.validate optional keyword arguments
"""
token = self.token_storage.get(user... | python | def authenticated(self, user_token, **validation_context):
"""Checks if user is authenticated using token passed in argument
:param user_token: string representing token
:param validation_context: Token.validate optional keyword arguments
"""
token = self.token_storage.get(user... | [
"def",
"authenticated",
"(",
"self",
",",
"user_token",
",",
"*",
"*",
"validation_context",
")",
":",
"token",
"=",
"self",
".",
"token_storage",
".",
"get",
"(",
"user_token",
")",
"if",
"token",
"and",
"token",
".",
"validate",
"(",
"user_token",
",",
... | Checks if user is authenticated using token passed in argument
:param user_token: string representing token
:param validation_context: Token.validate optional keyword arguments | [
"Checks",
"if",
"user",
"is",
"authenticated",
"using",
"token",
"passed",
"in",
"argument"
] | d84f90ffd706c0f491af3539cd438e13771ada7e | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L114-L125 |
53,016 | KujiraProject/Flask-PAM | flask_pam/auth.py | Auth.group_authenticated | def group_authenticated(self, user_token, group):
"""Checks if user represented by token is in group.
:param user_token: string representing token
:param group: group's name
"""
if self.authenticated(user_token):
token = self.token_storage.get(user_token)
... | python | def group_authenticated(self, user_token, group):
"""Checks if user represented by token is in group.
:param user_token: string representing token
:param group: group's name
"""
if self.authenticated(user_token):
token = self.token_storage.get(user_token)
... | [
"def",
"group_authenticated",
"(",
"self",
",",
"user_token",
",",
"group",
")",
":",
"if",
"self",
".",
"authenticated",
"(",
"user_token",
")",
":",
"token",
"=",
"self",
".",
"token_storage",
".",
"get",
"(",
"user_token",
")",
"groups",
"=",
"self",
... | Checks if user represented by token is in group.
:param user_token: string representing token
:param group: group's name | [
"Checks",
"if",
"user",
"represented",
"by",
"token",
"is",
"in",
"group",
"."
] | d84f90ffd706c0f491af3539cd438e13771ada7e | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L127-L140 |
53,017 | KujiraProject/Flask-PAM | flask_pam/auth.py | Auth.get_groups | def get_groups(self, username):
"""Returns list of groups in which user is.
:param username: name of Linux user
"""
groups = []
for group in grp.getgrall():
if username in group.gr_mem:
groups.append(group.gr_name)
return groups | python | def get_groups(self, username):
"""Returns list of groups in which user is.
:param username: name of Linux user
"""
groups = []
for group in grp.getgrall():
if username in group.gr_mem:
groups.append(group.gr_name)
return groups | [
"def",
"get_groups",
"(",
"self",
",",
"username",
")",
":",
"groups",
"=",
"[",
"]",
"for",
"group",
"in",
"grp",
".",
"getgrall",
"(",
")",
":",
"if",
"username",
"in",
"group",
".",
"gr_mem",
":",
"groups",
".",
"append",
"(",
"group",
".",
"gr_... | Returns list of groups in which user is.
:param username: name of Linux user | [
"Returns",
"list",
"of",
"groups",
"in",
"which",
"user",
"is",
"."
] | d84f90ffd706c0f491af3539cd438e13771ada7e | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L142-L152 |
53,018 | KujiraProject/Flask-PAM | flask_pam/auth.py | Auth.auth_required | def auth_required(self, view):
"""Decorator which checks if user is authenticated
Decorator for Flask's view which blocks not authenticated requests
:param view: Flask's view function
"""
@functools.wraps(view)
def decorated(*args, **kwargs):
log.in... | python | def auth_required(self, view):
"""Decorator which checks if user is authenticated
Decorator for Flask's view which blocks not authenticated requests
:param view: Flask's view function
"""
@functools.wraps(view)
def decorated(*args, **kwargs):
log.in... | [
"def",
"auth_required",
"(",
"self",
",",
"view",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"view",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"Trying to get access to protected resource: '... | Decorator which checks if user is authenticated
Decorator for Flask's view which blocks not authenticated requests
:param view: Flask's view function | [
"Decorator",
"which",
"checks",
"if",
"user",
"is",
"authenticated",
"Decorator",
"for",
"Flask",
"s",
"view",
"which",
"blocks",
"not",
"authenticated",
"requests"
] | d84f90ffd706c0f491af3539cd438e13771ada7e | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L155-L177 |
53,019 | KujiraProject/Flask-PAM | flask_pam/auth.py | Auth.group_required | def group_required(self, group):
"""Decorator which checks if user is in group
Decorator for Flask's view which blocks requests from not
authenticated users or if user is not member of specified group
:param group: group's name
"""
def decorator(view):
@fun... | python | def group_required(self, group):
"""Decorator which checks if user is in group
Decorator for Flask's view which blocks requests from not
authenticated users or if user is not member of specified group
:param group: group's name
"""
def decorator(view):
@fun... | [
"def",
"group_required",
"(",
"self",
",",
"group",
")",
":",
"def",
"decorator",
"(",
"view",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"view",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
... | Decorator which checks if user is in group
Decorator for Flask's view which blocks requests from not
authenticated users or if user is not member of specified group
:param group: group's name | [
"Decorator",
"which",
"checks",
"if",
"user",
"is",
"in",
"group"
] | d84f90ffd706c0f491af3539cd438e13771ada7e | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L179-L204 |
53,020 | rocky/python-filecache | pyficache/main.py | pyc2py | def pyc2py(filename):
"""
Find corresponding .py name given a .pyc or .pyo
"""
if re.match(".*py[co]$", filename):
if PYTHON3:
return re.sub(r'(.*)__pycache__/(.+)\.cpython-%s.py[co]$' % PYVER,
'\\1\\2.py',
filename)
else:
... | python | def pyc2py(filename):
"""
Find corresponding .py name given a .pyc or .pyo
"""
if re.match(".*py[co]$", filename):
if PYTHON3:
return re.sub(r'(.*)__pycache__/(.+)\.cpython-%s.py[co]$' % PYVER,
'\\1\\2.py',
filename)
else:
... | [
"def",
"pyc2py",
"(",
"filename",
")",
":",
"if",
"re",
".",
"match",
"(",
"\".*py[co]$\"",
",",
"filename",
")",
":",
"if",
"PYTHON3",
":",
"return",
"re",
".",
"sub",
"(",
"r'(.*)__pycache__/(.+)\\.cpython-%s.py[co]$'",
"%",
"PYVER",
",",
"'\\\\1\\\\2.py'",
... | Find corresponding .py name given a .pyc or .pyo | [
"Find",
"corresponding",
".",
"py",
"name",
"given",
"a",
".",
"pyc",
"or",
".",
"pyo"
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L94-L105 |
53,021 | rocky/python-filecache | pyficache/main.py | clear_file_cache | def clear_file_cache(filename=None):
"""Clear the file cache. If no filename is given clear it entirely.
if a filename is given, clear just that filename."""
global file_cache, file2file_remap, file2file_remap_lines
if filename is not None:
if filename in file_cache:
del file_cache[f... | python | def clear_file_cache(filename=None):
"""Clear the file cache. If no filename is given clear it entirely.
if a filename is given, clear just that filename."""
global file_cache, file2file_remap, file2file_remap_lines
if filename is not None:
if filename in file_cache:
del file_cache[f... | [
"def",
"clear_file_cache",
"(",
"filename",
"=",
"None",
")",
":",
"global",
"file_cache",
",",
"file2file_remap",
",",
"file2file_remap_lines",
"if",
"filename",
"is",
"not",
"None",
":",
"if",
"filename",
"in",
"file_cache",
":",
"del",
"file_cache",
"[",
"f... | Clear the file cache. If no filename is given clear it entirely.
if a filename is given, clear just that filename. | [
"Clear",
"the",
"file",
"cache",
".",
"If",
"no",
"filename",
"is",
"given",
"clear",
"it",
"entirely",
".",
"if",
"a",
"filename",
"is",
"given",
"clear",
"just",
"that",
"filename",
"."
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L198-L211 |
53,022 | rocky/python-filecache | pyficache/main.py | clear_file_format_cache | def clear_file_format_cache():
"""Remove syntax-formatted lines in the cache. Use this
when you change the Pygments syntax or Token formatting
and want to redo how files may have previously been
syntax marked."""
for fname, cache_info in file_cache.items():
for format, lines in cache_info.li... | python | def clear_file_format_cache():
"""Remove syntax-formatted lines in the cache. Use this
when you change the Pygments syntax or Token formatting
and want to redo how files may have previously been
syntax marked."""
for fname, cache_info in file_cache.items():
for format, lines in cache_info.li... | [
"def",
"clear_file_format_cache",
"(",
")",
":",
"for",
"fname",
",",
"cache_info",
"in",
"file_cache",
".",
"items",
"(",
")",
":",
"for",
"format",
",",
"lines",
"in",
"cache_info",
".",
"lines",
".",
"items",
"(",
")",
":",
"if",
"'plain'",
"==",
"f... | Remove syntax-formatted lines in the cache. Use this
when you change the Pygments syntax or Token formatting
and want to redo how files may have previously been
syntax marked. | [
"Remove",
"syntax",
"-",
"formatted",
"lines",
"in",
"the",
"cache",
".",
"Use",
"this",
"when",
"you",
"change",
"the",
"Pygments",
"syntax",
"or",
"Token",
"formatting",
"and",
"want",
"to",
"redo",
"how",
"files",
"may",
"have",
"previously",
"been",
"s... | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L213-L224 |
53,023 | rocky/python-filecache | pyficache/main.py | cache_script | def cache_script(script, text, opts={}):
"""Cache script if it is not already cached."""
global script_cache
if script not in script_cache:
update_script_cache(script, text, opts)
pass
return script | python | def cache_script(script, text, opts={}):
"""Cache script if it is not already cached."""
global script_cache
if script not in script_cache:
update_script_cache(script, text, opts)
pass
return script | [
"def",
"cache_script",
"(",
"script",
",",
"text",
",",
"opts",
"=",
"{",
"}",
")",
":",
"global",
"script_cache",
"if",
"script",
"not",
"in",
"script_cache",
":",
"update_script_cache",
"(",
"script",
",",
"text",
",",
"opts",
")",
"pass",
"return",
"s... | Cache script if it is not already cached. | [
"Cache",
"script",
"if",
"it",
"is",
"not",
"already",
"cached",
"."
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L269-L275 |
53,024 | rocky/python-filecache | pyficache/main.py | cache_file | def cache_file(filename, reload_on_change=False, opts=default_opts):
"""Cache filename if it is not already cached.
Return the expanded filename for it in the cache
or nil if we can not find the file."""
filename = pyc2py(filename)
if filename in file_cache:
if reload_on_change: checkcache(f... | python | def cache_file(filename, reload_on_change=False, opts=default_opts):
"""Cache filename if it is not already cached.
Return the expanded filename for it in the cache
or nil if we can not find the file."""
filename = pyc2py(filename)
if filename in file_cache:
if reload_on_change: checkcache(f... | [
"def",
"cache_file",
"(",
"filename",
",",
"reload_on_change",
"=",
"False",
",",
"opts",
"=",
"default_opts",
")",
":",
"filename",
"=",
"pyc2py",
"(",
"filename",
")",
"if",
"filename",
"in",
"file_cache",
":",
"if",
"reload_on_change",
":",
"checkcache",
... | Cache filename if it is not already cached.
Return the expanded filename for it in the cache
or nil if we can not find the file. | [
"Cache",
"filename",
"if",
"it",
"is",
"not",
"already",
"cached",
".",
"Return",
"the",
"expanded",
"filename",
"for",
"it",
"in",
"the",
"cache",
"or",
"nil",
"if",
"we",
"can",
"not",
"find",
"the",
"file",
"."
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L292-L307 |
53,025 | rocky/python-filecache | pyficache/main.py | is_cached | def is_cached(file_or_script):
"""Return True if file_or_script is cached"""
if isinstance(file_or_script, str):
return unmap_file(file_or_script) in file_cache
else:
return is_cached_script(file_or_script)
return | python | def is_cached(file_or_script):
"""Return True if file_or_script is cached"""
if isinstance(file_or_script, str):
return unmap_file(file_or_script) in file_cache
else:
return is_cached_script(file_or_script)
return | [
"def",
"is_cached",
"(",
"file_or_script",
")",
":",
"if",
"isinstance",
"(",
"file_or_script",
",",
"str",
")",
":",
"return",
"unmap_file",
"(",
"file_or_script",
")",
"in",
"file_cache",
"else",
":",
"return",
"is_cached_script",
"(",
"file_or_script",
")",
... | Return True if file_or_script is cached | [
"Return",
"True",
"if",
"file_or_script",
"is",
"cached"
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L309-L315 |
53,026 | rocky/python-filecache | pyficache/main.py | path | def path(filename):
"""Return full filename path for filename"""
filename = unmap_file(filename)
if filename not in file_cache:
return None
return file_cache[filename].path | python | def path(filename):
"""Return full filename path for filename"""
filename = unmap_file(filename)
if filename not in file_cache:
return None
return file_cache[filename].path | [
"def",
"path",
"(",
"filename",
")",
":",
"filename",
"=",
"unmap_file",
"(",
"filename",
")",
"if",
"filename",
"not",
"in",
"file_cache",
":",
"return",
"None",
"return",
"file_cache",
"[",
"filename",
"]",
".",
"path"
] | Return full filename path for filename | [
"Return",
"full",
"filename",
"path",
"for",
"filename"
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L407-L412 |
53,027 | rocky/python-filecache | pyficache/main.py | remap_file_lines | def remap_file_lines(from_path, to_path, line_map_list):
"""Adds line_map list to the list of association of from_file to
to to_file"""
from_path = pyc2py(from_path)
cache_file(to_path)
remap_entry = file2file_remap_lines.get(to_path)
if remap_entry:
new_list = list(remap_entry.from_t... | python | def remap_file_lines(from_path, to_path, line_map_list):
"""Adds line_map list to the list of association of from_file to
to to_file"""
from_path = pyc2py(from_path)
cache_file(to_path)
remap_entry = file2file_remap_lines.get(to_path)
if remap_entry:
new_list = list(remap_entry.from_t... | [
"def",
"remap_file_lines",
"(",
"from_path",
",",
"to_path",
",",
"line_map_list",
")",
":",
"from_path",
"=",
"pyc2py",
"(",
"from_path",
")",
"cache_file",
"(",
"to_path",
")",
"remap_entry",
"=",
"file2file_remap_lines",
".",
"get",
"(",
"to_path",
")",
"if... | Adds line_map list to the list of association of from_file to
to to_file | [
"Adds",
"line_map",
"list",
"to",
"the",
"list",
"of",
"association",
"of",
"from_file",
"to",
"to",
"to_file"
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L419-L434 |
53,028 | rocky/python-filecache | pyficache/main.py | sha1 | def sha1(filename):
"""Return SHA1 of filename."""
filename = unmap_file(filename)
if filename not in file_cache:
cache_file(filename)
if filename not in file_cache:
return None
pass
if file_cache[filename].sha1:
return file_cache[filename].sha1.hexdigest()
... | python | def sha1(filename):
"""Return SHA1 of filename."""
filename = unmap_file(filename)
if filename not in file_cache:
cache_file(filename)
if filename not in file_cache:
return None
pass
if file_cache[filename].sha1:
return file_cache[filename].sha1.hexdigest()
... | [
"def",
"sha1",
"(",
"filename",
")",
":",
"filename",
"=",
"unmap_file",
"(",
"filename",
")",
"if",
"filename",
"not",
"in",
"file_cache",
":",
"cache_file",
"(",
"filename",
")",
"if",
"filename",
"not",
"in",
"file_cache",
":",
"return",
"None",
"pass",... | Return SHA1 of filename. | [
"Return",
"SHA1",
"of",
"filename",
"."
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L445-L460 |
53,029 | rocky/python-filecache | pyficache/main.py | size | def size(filename, use_cache_only=False):
"""Return the number of lines in filename. If `use_cache_only' is False,
we'll try to fetch the file if it is not cached."""
filename = unmap_file(filename)
if filename not in file_cache:
if not use_cache_only: cache_file(filename)
if filename no... | python | def size(filename, use_cache_only=False):
"""Return the number of lines in filename. If `use_cache_only' is False,
we'll try to fetch the file if it is not cached."""
filename = unmap_file(filename)
if filename not in file_cache:
if not use_cache_only: cache_file(filename)
if filename no... | [
"def",
"size",
"(",
"filename",
",",
"use_cache_only",
"=",
"False",
")",
":",
"filename",
"=",
"unmap_file",
"(",
"filename",
")",
"if",
"filename",
"not",
"in",
"file_cache",
":",
"if",
"not",
"use_cache_only",
":",
"cache_file",
"(",
"filename",
")",
"i... | Return the number of lines in filename. If `use_cache_only' is False,
we'll try to fetch the file if it is not cached. | [
"Return",
"the",
"number",
"of",
"lines",
"in",
"filename",
".",
"If",
"use_cache_only",
"is",
"False",
"we",
"ll",
"try",
"to",
"fetch",
"the",
"file",
"if",
"it",
"is",
"not",
"cached",
"."
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L462-L471 |
53,030 | rocky/python-filecache | pyficache/main.py | maxline | def maxline(filename, use_cache_only=False):
"""Return the maximum line number filename after taking into account
line remapping. If no remapping then this is the same as size"""
if filename not in file2file_remap_lines:
return size(filename, use_cache_only)
max_lineno = -1
remap_line_entry ... | python | def maxline(filename, use_cache_only=False):
"""Return the maximum line number filename after taking into account
line remapping. If no remapping then this is the same as size"""
if filename not in file2file_remap_lines:
return size(filename, use_cache_only)
max_lineno = -1
remap_line_entry ... | [
"def",
"maxline",
"(",
"filename",
",",
"use_cache_only",
"=",
"False",
")",
":",
"if",
"filename",
"not",
"in",
"file2file_remap_lines",
":",
"return",
"size",
"(",
"filename",
",",
"use_cache_only",
")",
"max_lineno",
"=",
"-",
"1",
"remap_line_entry",
"=",
... | Return the maximum line number filename after taking into account
line remapping. If no remapping then this is the same as size | [
"Return",
"the",
"maximum",
"line",
"number",
"filename",
"after",
"taking",
"into",
"account",
"line",
"remapping",
".",
"If",
"no",
"remapping",
"then",
"this",
"is",
"the",
"same",
"as",
"size"
] | 60709ccd837ef5df001faf3cb02d4979ba342a23 | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L473-L487 |
53,031 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/session_ticket_auth.py | SessionTktAuthentication.remember_ticket | async def remember_ticket(self, request, ticket):
"""Called to store the ticket data for a request.
Ticket data is stored in the aiohttp_session object
Args:
request: aiohttp Request object.
ticket: String like object representing the ticket to be stored.
"""
... | python | async def remember_ticket(self, request, ticket):
"""Called to store the ticket data for a request.
Ticket data is stored in the aiohttp_session object
Args:
request: aiohttp Request object.
ticket: String like object representing the ticket to be stored.
"""
... | [
"async",
"def",
"remember_ticket",
"(",
"self",
",",
"request",
",",
"ticket",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"session",
"[",
"self",
".",
"cookie_name",
"]",
"=",
"ticket"
] | Called to store the ticket data for a request.
Ticket data is stored in the aiohttp_session object
Args:
request: aiohttp Request object.
ticket: String like object representing the ticket to be stored. | [
"Called",
"to",
"store",
"the",
"ticket",
"data",
"for",
"a",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/session_ticket_auth.py#L10-L20 |
53,032 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/session_ticket_auth.py | SessionTktAuthentication.forget_ticket | async def forget_ticket(self, request):
"""Called to forget the ticket data a request
Args:
request: aiohttp Request object.
"""
session = await get_session(request)
session.pop(self.cookie_name, '') | python | async def forget_ticket(self, request):
"""Called to forget the ticket data a request
Args:
request: aiohttp Request object.
"""
session = await get_session(request)
session.pop(self.cookie_name, '') | [
"async",
"def",
"forget_ticket",
"(",
"self",
",",
"request",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"session",
".",
"pop",
"(",
"self",
".",
"cookie_name",
",",
"''",
")"
] | Called to forget the ticket data a request
Args:
request: aiohttp Request object. | [
"Called",
"to",
"forget",
"the",
"ticket",
"data",
"a",
"request"
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/session_ticket_auth.py#L22-L29 |
53,033 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/session_ticket_auth.py | SessionTktAuthentication.get_ticket | async def get_ticket(self, request):
"""Called to return the ticket for a request.
Args:
request: aiohttp Request object.
Returns:
A ticket (string like) object, or None if no ticket is available
for the passed request.
"""
session = await ge... | python | async def get_ticket(self, request):
"""Called to return the ticket for a request.
Args:
request: aiohttp Request object.
Returns:
A ticket (string like) object, or None if no ticket is available
for the passed request.
"""
session = await ge... | [
"async",
"def",
"get_ticket",
"(",
"self",
",",
"request",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"return",
"session",
".",
"get",
"(",
"self",
".",
"cookie_name",
")"
] | Called to return the ticket for a request.
Args:
request: aiohttp Request object.
Returns:
A ticket (string like) object, or None if no ticket is available
for the passed request. | [
"Called",
"to",
"return",
"the",
"ticket",
"for",
"a",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/session_ticket_auth.py#L31-L42 |
53,034 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/auth.py | auth_middleware | def auth_middleware(policy):
"""Returns a aiohttp_auth middleware factory for use by the aiohttp
application object.
Args:
policy: A authentication policy with a base class of
AbstractAuthentication.
"""
assert isinstance(policy, AbstractAuthentication)
async def _auth_midd... | python | def auth_middleware(policy):
"""Returns a aiohttp_auth middleware factory for use by the aiohttp
application object.
Args:
policy: A authentication policy with a base class of
AbstractAuthentication.
"""
assert isinstance(policy, AbstractAuthentication)
async def _auth_midd... | [
"def",
"auth_middleware",
"(",
"policy",
")",
":",
"assert",
"isinstance",
"(",
"policy",
",",
"AbstractAuthentication",
")",
"async",
"def",
"_auth_middleware_factory",
"(",
"app",
",",
"handler",
")",
":",
"async",
"def",
"_middleware_handler",
"(",
"request",
... | Returns a aiohttp_auth middleware factory for use by the aiohttp
application object.
Args:
policy: A authentication policy with a base class of
AbstractAuthentication. | [
"Returns",
"a",
"aiohttp_auth",
"middleware",
"factory",
"for",
"use",
"by",
"the",
"aiohttp",
"application",
"object",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/auth.py#L10-L36 |
53,035 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/auth.py | get_auth | async def get_auth(request):
"""Returns the user_id associated with a particular request.
Args:
request: aiohttp Request object.
Returns:
The user_id associated with the request, or None if no user is
associated with the request.
Raises:
RuntimeError: Middleware is not... | python | async def get_auth(request):
"""Returns the user_id associated with a particular request.
Args:
request: aiohttp Request object.
Returns:
The user_id associated with the request, or None if no user is
associated with the request.
Raises:
RuntimeError: Middleware is not... | [
"async",
"def",
"get_auth",
"(",
"request",
")",
":",
"auth_val",
"=",
"request",
".",
"get",
"(",
"AUTH_KEY",
")",
"if",
"auth_val",
":",
"return",
"auth_val",
"auth_policy",
"=",
"request",
".",
"get",
"(",
"POLICY_KEY",
")",
"if",
"auth_policy",
"is",
... | Returns the user_id associated with a particular request.
Args:
request: aiohttp Request object.
Returns:
The user_id associated with the request, or None if no user is
associated with the request.
Raises:
RuntimeError: Middleware is not installed | [
"Returns",
"the",
"user_id",
"associated",
"with",
"a",
"particular",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/auth.py#L39-L62 |
53,036 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/auth.py | remember | async def remember(request, user_id):
"""Called to store and remember the userid for a request
Args:
request: aiohttp Request object.
user_id: String representing the user_id to remember
Raises:
RuntimeError: Middleware is not installed
"""
auth_policy = request.get(POLICY_... | python | async def remember(request, user_id):
"""Called to store and remember the userid for a request
Args:
request: aiohttp Request object.
user_id: String representing the user_id to remember
Raises:
RuntimeError: Middleware is not installed
"""
auth_policy = request.get(POLICY_... | [
"async",
"def",
"remember",
"(",
"request",
",",
"user_id",
")",
":",
"auth_policy",
"=",
"request",
".",
"get",
"(",
"POLICY_KEY",
")",
"if",
"auth_policy",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'auth_middleware not installed'",
")",
"return",
"aw... | Called to store and remember the userid for a request
Args:
request: aiohttp Request object.
user_id: String representing the user_id to remember
Raises:
RuntimeError: Middleware is not installed | [
"Called",
"to",
"store",
"and",
"remember",
"the",
"userid",
"for",
"a",
"request"
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/auth.py#L65-L79 |
53,037 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/auth.py | forget | async def forget(request):
"""Called to forget the userid for a request
Args:
request: aiohttp Request object
Raises:
RuntimeError: Middleware is not installed
"""
auth_policy = request.get(POLICY_KEY)
if auth_policy is None:
raise RuntimeError('auth_middleware not inst... | python | async def forget(request):
"""Called to forget the userid for a request
Args:
request: aiohttp Request object
Raises:
RuntimeError: Middleware is not installed
"""
auth_policy = request.get(POLICY_KEY)
if auth_policy is None:
raise RuntimeError('auth_middleware not inst... | [
"async",
"def",
"forget",
"(",
"request",
")",
":",
"auth_policy",
"=",
"request",
".",
"get",
"(",
"POLICY_KEY",
")",
"if",
"auth_policy",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'auth_middleware not installed'",
")",
"return",
"await",
"auth_policy",... | Called to forget the userid for a request
Args:
request: aiohttp Request object
Raises:
RuntimeError: Middleware is not installed | [
"Called",
"to",
"forget",
"the",
"userid",
"for",
"a",
"request"
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/auth.py#L82-L95 |
53,038 | theycallmeswift/BreakfastSerial | BreakfastSerial/util.py | debounce | def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
fn(*args, **kwargs)
try:
... | python | def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
fn(*args, **kwargs)
try:
... | [
"def",
"debounce",
"(",
"wait",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"def",
"debounced",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"call_it",
"(",
")",
":",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. | [
"Decorator",
"that",
"will",
"postpone",
"a",
"functions",
"execution",
"until",
"after",
"wait",
"seconds",
"have",
"elapsed",
"since",
"the",
"last",
"time",
"it",
"was",
"invoked",
"."
] | cb6072f8c200838fc580afe1a04b80bae9509ce8 | https://github.com/theycallmeswift/BreakfastSerial/blob/cb6072f8c200838fc580afe1a04b80bae9509ce8/BreakfastSerial/util.py#L40-L55 |
53,039 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/cookie_ticket_auth.py | CookieTktAuthentication.process_response | async def process_response(self, request, response):
"""Called to perform any processing of the response required.
This function stores any cookie data in the COOKIE_AUTH_KEY as a
cookie in the response object. If the value is a empty string, the
associated cookie is deleted instead.
... | python | async def process_response(self, request, response):
"""Called to perform any processing of the response required.
This function stores any cookie data in the COOKIE_AUTH_KEY as a
cookie in the response object. If the value is a empty string, the
associated cookie is deleted instead.
... | [
"async",
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"await",
"super",
"(",
")",
".",
"process_response",
"(",
"request",
",",
"response",
")",
"if",
"COOKIE_AUTH_KEY",
"in",
"request",
":",
"if",
"response",
".",
"st... | Called to perform any processing of the response required.
This function stores any cookie data in the COOKIE_AUTH_KEY as a
cookie in the response object. If the value is a empty string, the
associated cookie is deleted instead.
This function requires the response to be a aiohttp Respo... | [
"Called",
"to",
"perform",
"any",
"processing",
"of",
"the",
"response",
"required",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/cookie_ticket_auth.py#L45-L72 |
53,040 | pschmitt/python-opsview | opsview/opsview.py | get_args | def get_args():
'''
Parse CLI args
'''
parser = argparse.ArgumentParser(description='Process args')
parser.Add_argument(
'-H', '--host',
required=True,
action='store',
help='Remote host to connect to'
)
parser.add_argument(
'-P', '--port',
type... | python | def get_args():
'''
Parse CLI args
'''
parser = argparse.ArgumentParser(description='Process args')
parser.Add_argument(
'-H', '--host',
required=True,
action='store',
help='Remote host to connect to'
)
parser.add_argument(
'-P', '--port',
type... | [
"def",
"get_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Process args'",
")",
"parser",
".",
"Add_argument",
"(",
"'-H'",
",",
"'--host'",
",",
"required",
"=",
"True",
",",
"action",
"=",
"'store'",
",... | Parse CLI args | [
"Parse",
"CLI",
"args"
] | 720acc06c491db32d18c79d20f04cae16e57a7fb | https://github.com/pschmitt/python-opsview/blob/720acc06c491db32d18c79d20f04cae16e57a7fb/opsview/opsview.py#L441-L497 |
53,041 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/ticket_auth.py | TktAuthentication.remember | async def remember(self, request, user_id):
"""Called to store the userid for a request.
This function creates a ticket from the request and user_id, and calls
the abstract function remember_ticket() to store the ticket.
Args:
request: aiohttp Request object.
us... | python | async def remember(self, request, user_id):
"""Called to store the userid for a request.
This function creates a ticket from the request and user_id, and calls
the abstract function remember_ticket() to store the ticket.
Args:
request: aiohttp Request object.
us... | [
"async",
"def",
"remember",
"(",
"self",
",",
"request",
",",
"user_id",
")",
":",
"ticket",
"=",
"self",
".",
"_new_ticket",
"(",
"request",
",",
"user_id",
")",
"await",
"self",
".",
"remember_ticket",
"(",
"request",
",",
"ticket",
")"
] | Called to store the userid for a request.
This function creates a ticket from the request and user_id, and calls
the abstract function remember_ticket() to store the ticket.
Args:
request: aiohttp Request object.
user_id: String representing the user_id to remember | [
"Called",
"to",
"store",
"the",
"userid",
"for",
"a",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/ticket_auth.py#L61-L72 |
53,042 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/ticket_auth.py | TktAuthentication.get | async def get(self, request):
"""Gets the user_id for the request.
Gets the ticket for the request using the get_ticket() function, and
authenticates the ticket.
Args:
request: aiohttp Request object.
Returns:
The userid for the request, or None if the ... | python | async def get(self, request):
"""Gets the user_id for the request.
Gets the ticket for the request using the get_ticket() function, and
authenticates the ticket.
Args:
request: aiohttp Request object.
Returns:
The userid for the request, or None if the ... | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"ticket",
"=",
"await",
"self",
".",
"get_ticket",
"(",
"request",
")",
"if",
"ticket",
"is",
"None",
":",
"return",
"None",
"try",
":",
"# Returns a tuple of (user_id, token, userdata, validuntil)",
... | Gets the user_id for the request.
Gets the ticket for the request using the get_ticket() function, and
authenticates the ticket.
Args:
request: aiohttp Request object.
Returns:
The userid for the request, or None if the ticket is not
authenticated. | [
"Gets",
"the",
"user_id",
"for",
"the",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/ticket_auth.py#L85-L117 |
53,043 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/ticket_auth.py | TktAuthentication.process_response | async def process_response(self, request, response):
"""If a reissue was requested, only reiisue if the response was a
valid 2xx response
"""
if _REISSUE_KEY in request:
if (response.started or
not isinstance(response, web.Response) or
response... | python | async def process_response(self, request, response):
"""If a reissue was requested, only reiisue if the response was a
valid 2xx response
"""
if _REISSUE_KEY in request:
if (response.started or
not isinstance(response, web.Response) or
response... | [
"async",
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"_REISSUE_KEY",
"in",
"request",
":",
"if",
"(",
"response",
".",
"started",
"or",
"not",
"isinstance",
"(",
"response",
",",
"web",
".",
"Response",
")",
"... | If a reissue was requested, only reiisue if the response was a
valid 2xx response | [
"If",
"a",
"reissue",
"was",
"requested",
"only",
"reiisue",
"if",
"the",
"response",
"was",
"a",
"valid",
"2xx",
"response"
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/ticket_auth.py#L119-L129 |
53,044 | gnarlychicken/aiohttp_auth | aiohttp_auth/acl/decorators.py | acl_required | def acl_required(permission, context):
"""Returns a decorator that checks if a user has the requested permission
from the passed acl context.
This function constructs a decorator that can be used to check a aiohttp's
view for authorization before calling it. It uses the get_permission()
function to... | python | def acl_required(permission, context):
"""Returns a decorator that checks if a user has the requested permission
from the passed acl context.
This function constructs a decorator that can be used to check a aiohttp's
view for authorization before calling it. It uses the get_permission()
function to... | [
"def",
"acl_required",
"(",
"permission",
",",
"context",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"*",
"args",
")",
":",
"request",
"=",
"args",
"[",
"-",
"1",
"]",
"if",
... | Returns a decorator that checks if a user has the requested permission
from the passed acl context.
This function constructs a decorator that can be used to check a aiohttp's
view for authorization before calling it. It uses the get_permission()
function to check the request against the passed permissi... | [
"Returns",
"a",
"decorator",
"that",
"checks",
"if",
"a",
"user",
"has",
"the",
"requested",
"permission",
"from",
"the",
"passed",
"acl",
"context",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/acl/decorators.py#L6-L44 |
53,045 | predicador37/pyjstat | pyjstat/pyjstat.py | check_version_2 | def check_version_2(dataset):
"""Checks if json-stat version attribute exists and is equal or greater \
than 2.0 for a given dataset.
Args:
dataset (OrderedDict): data in JSON-stat format, previously \
deserialized to a python object by \
... | python | def check_version_2(dataset):
"""Checks if json-stat version attribute exists and is equal or greater \
than 2.0 for a given dataset.
Args:
dataset (OrderedDict): data in JSON-stat format, previously \
deserialized to a python object by \
... | [
"def",
"check_version_2",
"(",
"dataset",
")",
":",
"if",
"float",
"(",
"dataset",
".",
"get",
"(",
"'version'",
")",
")",
">=",
"2.0",
"if",
"dataset",
".",
"get",
"(",
"'version'",
")",
"else",
"False",
":",
"return",
"True",
"else",
":",
"return",
... | Checks if json-stat version attribute exists and is equal or greater \
than 2.0 for a given dataset.
Args:
dataset (OrderedDict): data in JSON-stat format, previously \
deserialized to a python object by \
json.load() or json.... | [
"Checks",
"if",
"json",
"-",
"stat",
"version",
"attribute",
"exists",
"and",
"is",
"equal",
"or",
"greater",
"\\",
"than",
"2",
".",
"0",
"for",
"a",
"given",
"dataset",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L99-L119 |
53,046 | predicador37/pyjstat | pyjstat/pyjstat.py | unnest_collection | def unnest_collection(collection, df_list):
"""Unnest collection structure extracting all its datasets and converting \
them to Pandas Dataframes.
Args:
collection (OrderedDict): data in JSON-stat format, previously \
deserialized to a python objec... | python | def unnest_collection(collection, df_list):
"""Unnest collection structure extracting all its datasets and converting \
them to Pandas Dataframes.
Args:
collection (OrderedDict): data in JSON-stat format, previously \
deserialized to a python objec... | [
"def",
"unnest_collection",
"(",
"collection",
",",
"df_list",
")",
":",
"for",
"item",
"in",
"collection",
"[",
"'link'",
"]",
"[",
"'item'",
"]",
":",
"if",
"item",
"[",
"'class'",
"]",
"==",
"'dataset'",
":",
"df_list",
".",
"append",
"(",
"Dataset",
... | Unnest collection structure extracting all its datasets and converting \
them to Pandas Dataframes.
Args:
collection (OrderedDict): data in JSON-stat format, previously \
deserialized to a python object by \
json.l... | [
"Unnest",
"collection",
"structure",
"extracting",
"all",
"its",
"datasets",
"and",
"converting",
"\\",
"them",
"to",
"Pandas",
"Dataframes",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L122-L142 |
53,047 | predicador37/pyjstat | pyjstat/pyjstat.py | get_dimensions | def get_dimensions(js_dict, naming):
"""Get dimensions from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
naming (string, optional): dimension naming. Possible values: 'label' \
or 'id'.
Returns:
dimensions (list): lis... | python | def get_dimensions(js_dict, naming):
"""Get dimensions from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
naming (string, optional): dimension naming. Possible values: 'label' \
or 'id'.
Returns:
dimensions (list): lis... | [
"def",
"get_dimensions",
"(",
"js_dict",
",",
"naming",
")",
":",
"dimensions",
"=",
"[",
"]",
"dim_names",
"=",
"[",
"]",
"if",
"check_version_2",
"(",
"js_dict",
")",
":",
"dimension_dict",
"=",
"js_dict",
"else",
":",
"dimension_dict",
"=",
"js_dict",
"... | Get dimensions from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
naming (string, optional): dimension naming. Possible values: 'label' \
or 'id'.
Returns:
dimensions (list): list of pandas data frames with dimension \
... | [
"Get",
"dimensions",
"from",
"input",
"data",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L163-L195 |
53,048 | predicador37/pyjstat | pyjstat/pyjstat.py | get_dim_label | def get_dim_label(js_dict, dim, input="dataset"):
"""Get label from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_label(pandas.DataFrame): DataFrame with label-based dimension d... | python | def get_dim_label(js_dict, dim, input="dataset"):
"""Get label from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_label(pandas.DataFrame): DataFrame with label-based dimension d... | [
"def",
"get_dim_label",
"(",
"js_dict",
",",
"dim",
",",
"input",
"=",
"\"dataset\"",
")",
":",
"if",
"input",
"==",
"'dataset'",
":",
"input",
"=",
"js_dict",
"[",
"'dimension'",
"]",
"[",
"dim",
"]",
"label_col",
"=",
"'label'",
"elif",
"input",
"==",
... | Get label from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_label(pandas.DataFrame): DataFrame with label-based dimension data. | [
"Get",
"label",
"from",
"a",
"given",
"dimension",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L198-L251 |
53,049 | predicador37/pyjstat | pyjstat/pyjstat.py | get_dim_index | def get_dim_index(js_dict, dim):
"""Get index from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_index (pandas.DataFrame): DataFrame with index-based dimension data.
"""
... | python | def get_dim_index(js_dict, dim):
"""Get index from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_index (pandas.DataFrame): DataFrame with index-based dimension data.
"""
... | [
"def",
"get_dim_index",
"(",
"js_dict",
",",
"dim",
")",
":",
"try",
":",
"dim_index",
"=",
"js_dict",
"[",
"'dimension'",
"]",
"[",
"dim",
"]",
"[",
"'category'",
"]",
"[",
"'index'",
"]",
"except",
"KeyError",
":",
"dim_label",
"=",
"get_dim_label",
"(... | Get index from a given dimension.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
dim (string): dimension name obtained from JSON file.
Returns:
dim_index (pandas.DataFrame): DataFrame with index-based dimension data. | [
"Get",
"index",
"from",
"a",
"given",
"dimension",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L254-L284 |
53,050 | predicador37/pyjstat | pyjstat/pyjstat.py | get_values | def get_values(js_dict, value='value'):
"""Get values from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
value (string, optional): name of the value column. Defaults to 'value'.
Returns:
values (list): list of dataset values.
"""
values = js... | python | def get_values(js_dict, value='value'):
"""Get values from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
value (string, optional): name of the value column. Defaults to 'value'.
Returns:
values (list): list of dataset values.
"""
values = js... | [
"def",
"get_values",
"(",
"js_dict",
",",
"value",
"=",
"'value'",
")",
":",
"values",
"=",
"js_dict",
"[",
"value",
"]",
"if",
"type",
"(",
"values",
")",
"is",
"list",
":",
"if",
"type",
"(",
"values",
"[",
"0",
"]",
")",
"is",
"not",
"dict",
"... | Get values from input data.
Args:
js_dict (dict): dictionary containing dataset data and metadata.
value (string, optional): name of the value column. Defaults to 'value'.
Returns:
values (list): list of dataset values. | [
"Get",
"values",
"from",
"input",
"data",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L287-L315 |
53,051 | predicador37/pyjstat | pyjstat/pyjstat.py | get_df_row | def get_df_row(dimensions, naming='label', i=0, record=None):
"""Generate row dimension values for a pandas dataframe.
Args:
dimensions (list): list of pandas dataframes with dimension labels \
generated by get_dim_label or get_dim_index methods.
naming (string, optional): ... | python | def get_df_row(dimensions, naming='label', i=0, record=None):
"""Generate row dimension values for a pandas dataframe.
Args:
dimensions (list): list of pandas dataframes with dimension labels \
generated by get_dim_label or get_dim_index methods.
naming (string, optional): ... | [
"def",
"get_df_row",
"(",
"dimensions",
",",
"naming",
"=",
"'label'",
",",
"i",
"=",
"0",
",",
"record",
"=",
"None",
")",
":",
"check_input",
"(",
"naming",
")",
"if",
"i",
"==",
"0",
"or",
"record",
"is",
"None",
":",
"record",
"=",
"[",
"]",
... | Generate row dimension values for a pandas dataframe.
Args:
dimensions (list): list of pandas dataframes with dimension labels \
generated by get_dim_label or get_dim_index methods.
naming (string, optional): dimension naming. Possible values: 'label' \
... | [
"Generate",
"row",
"dimension",
"values",
"for",
"a",
"pandas",
"dataframe",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L318-L349 |
53,052 | predicador37/pyjstat | pyjstat/pyjstat.py | from_json_stat | def from_json_stat(datasets, naming='label', value='value'):
"""Decode JSON-stat formatted data into pandas.DataFrame object.
Args:
datasets(OrderedDict, list): data in JSON-stat format, previously \
deserialized to a python object by \
... | python | def from_json_stat(datasets, naming='label', value='value'):
"""Decode JSON-stat formatted data into pandas.DataFrame object.
Args:
datasets(OrderedDict, list): data in JSON-stat format, previously \
deserialized to a python object by \
... | [
"def",
"from_json_stat",
"(",
"datasets",
",",
"naming",
"=",
"'label'",
",",
"value",
"=",
"'value'",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Shouldn't use this function anymore! Now use read() methods of\"",
"\"Dataset, Collection or Dimension.\"",
",",
"DeprecationWar... | Decode JSON-stat formatted data into pandas.DataFrame object.
Args:
datasets(OrderedDict, list): data in JSON-stat format, previously \
deserialized to a python object by \
json.load() or json.loads(), for example.\
... | [
"Decode",
"JSON",
"-",
"stat",
"formatted",
"data",
"into",
"pandas",
".",
"DataFrame",
"object",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L396-L437 |
53,053 | predicador37/pyjstat | pyjstat/pyjstat.py | request | def request(path):
"""Send a request to a given URL accepting JSON format and return a \
deserialized Python object.
Args:
path (str): The URI to be requested.
Returns:
response: Deserialized JSON Python object.
Raises:
HTTPError: the HTTP error returned by the requested serv... | python | def request(path):
"""Send a request to a given URL accepting JSON format and return a \
deserialized Python object.
Args:
path (str): The URI to be requested.
Returns:
response: Deserialized JSON Python object.
Raises:
HTTPError: the HTTP error returned by the requested serv... | [
"def",
"request",
"(",
"path",
")",
":",
"headers",
"=",
"{",
"'Accept'",
":",
"'application/json'",
"}",
"try",
":",
"requested_object",
"=",
"requests",
".",
"get",
"(",
"path",
",",
"headers",
"=",
"headers",
")",
"requested_object",
".",
"raise_for_statu... | Send a request to a given URL accepting JSON format and return a \
deserialized Python object.
Args:
path (str): The URI to be requested.
Returns:
response: Deserialized JSON Python object.
Raises:
HTTPError: the HTTP error returned by the requested server.
InvalidURL: an i... | [
"Send",
"a",
"request",
"to",
"a",
"given",
"URL",
"accepting",
"JSON",
"format",
"and",
"return",
"a",
"\\",
"deserialized",
"Python",
"object",
"."
] | 45d671835a99eb573e1058cd43ce93ac4f85f9fa | https://github.com/predicador37/pyjstat/blob/45d671835a99eb573e1058cd43ce93ac4f85f9fa/pyjstat/pyjstat.py#L534-L568 |
53,054 | gnarlychicken/aiohttp_auth | aiohttp_auth/auth/decorators.py | auth_required | def auth_required(func):
"""Utility decorator that checks if a user has been authenticated for this
request.
Allows views to be decorated like:
@auth_required
def view_func(request):
pass
providing a simple means to ensure that whoever is calling the function has
the c... | python | def auth_required(func):
"""Utility decorator that checks if a user has been authenticated for this
request.
Allows views to be decorated like:
@auth_required
def view_func(request):
pass
providing a simple means to ensure that whoever is calling the function has
the c... | [
"def",
"auth_required",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"*",
"args",
")",
":",
"if",
"(",
"await",
"get_auth",
"(",
"args",
"[",
"-",
"1",
"]",
")",
")",
"is",
"None",
":",
"raise",
"web",
... | Utility decorator that checks if a user has been authenticated for this
request.
Allows views to be decorated like:
@auth_required
def view_func(request):
pass
providing a simple means to ensure that whoever is calling the function has
the correct authentication details.
... | [
"Utility",
"decorator",
"that",
"checks",
"if",
"a",
"user",
"has",
"been",
"authenticated",
"for",
"this",
"request",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/auth/decorators.py#L6-L33 |
53,055 | utapyngo/django-render-partial | django_render_partial/templatetags/render_partial.py | render_partial | def render_partial(parser, token):
"""
Inserts the output of a view, using fully qualified view name,
or view name from urls.py.
{% render_partial view_name arg[ arg2] k=v [k2=v2...] %}
IMPORTANT: the calling template must receive a context variable called
'request' containing the original H... | python | def render_partial(parser, token):
"""
Inserts the output of a view, using fully qualified view name,
or view name from urls.py.
{% render_partial view_name arg[ arg2] k=v [k2=v2...] %}
IMPORTANT: the calling template must receive a context variable called
'request' containing the original H... | [
"def",
"render_partial",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"tokens",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"tokens",
")",
"<",
"2",
":",
"raise",
"TemplateSyntaxError",
"... | Inserts the output of a view, using fully qualified view name,
or view name from urls.py.
{% render_partial view_name arg[ arg2] k=v [k2=v2...] %}
IMPORTANT: the calling template must receive a context variable called
'request' containing the original HttpRequest. This means you should be OK
wit... | [
"Inserts",
"the",
"output",
"of",
"a",
"view",
"using",
"fully",
"qualified",
"view",
"name",
"or",
"view",
"name",
"from",
"urls",
".",
"py",
"."
] | 37256e32a365adefddd88a58a809db3743790120 | https://github.com/utapyngo/django-render-partial/blob/37256e32a365adefddd88a58a809db3743790120/django_render_partial/templatetags/render_partial.py#L49-L80 |
53,056 | bavovanachte/sphinx-wavedrom | sphinxcontrib/wavedrom.py | render_wavedrom | def render_wavedrom(self, node, outpath, bname, format):
"""
Render a wavedrom image
"""
# Try to convert node, raise error with code on failure
try:
svgout = WaveDrom().renderWaveForm(0, json.loads(node['code']))
except JSONDecodeError as e:
raise SphinxError("Cannot render the... | python | def render_wavedrom(self, node, outpath, bname, format):
"""
Render a wavedrom image
"""
# Try to convert node, raise error with code on failure
try:
svgout = WaveDrom().renderWaveForm(0, json.loads(node['code']))
except JSONDecodeError as e:
raise SphinxError("Cannot render the... | [
"def",
"render_wavedrom",
"(",
"self",
",",
"node",
",",
"outpath",
",",
"bname",
",",
"format",
")",
":",
"# Try to convert node, raise error with code on failure",
"try",
":",
"svgout",
"=",
"WaveDrom",
"(",
")",
".",
"renderWaveForm",
"(",
"0",
",",
"json",
... | Render a wavedrom image | [
"Render",
"a",
"wavedrom",
"image"
] | a8cfb4422ba2163453db669348f273af2e72f324 | https://github.com/bavovanachte/sphinx-wavedrom/blob/a8cfb4422ba2163453db669348f273af2e72f324/sphinxcontrib/wavedrom.py#L130-L171 |
53,057 | bavovanachte/sphinx-wavedrom | sphinxcontrib/wavedrom.py | visit_wavedrom | def visit_wavedrom(self, node):
"""
Visit the wavedrom node
"""
format = determine_format(self.builder.supported_image_types)
if format is None:
raise SphinxError(__("Cannot determine a suitable output format"))
# Create random filename
bname = "wavedrom-{}".format(uuid4())
outp... | python | def visit_wavedrom(self, node):
"""
Visit the wavedrom node
"""
format = determine_format(self.builder.supported_image_types)
if format is None:
raise SphinxError(__("Cannot determine a suitable output format"))
# Create random filename
bname = "wavedrom-{}".format(uuid4())
outp... | [
"def",
"visit_wavedrom",
"(",
"self",
",",
"node",
")",
":",
"format",
"=",
"determine_format",
"(",
"self",
".",
"builder",
".",
"supported_image_types",
")",
"if",
"format",
"is",
"None",
":",
"raise",
"SphinxError",
"(",
"__",
"(",
"\"Cannot determine a sui... | Visit the wavedrom node | [
"Visit",
"the",
"wavedrom",
"node"
] | a8cfb4422ba2163453db669348f273af2e72f324 | https://github.com/bavovanachte/sphinx-wavedrom/blob/a8cfb4422ba2163453db669348f273af2e72f324/sphinxcontrib/wavedrom.py#L174-L197 |
53,058 | bavovanachte/sphinx-wavedrom | sphinxcontrib/wavedrom.py | doctree_resolved | def doctree_resolved(app, doctree, fromdocname):
"""
When the document, and all the links are fully resolved, we inject one
raw html element for running the command for processing the wavedrom
diagrams at the onload event.
"""
# Skip for non-html or if javascript is not inlined
if not app.en... | python | def doctree_resolved(app, doctree, fromdocname):
"""
When the document, and all the links are fully resolved, we inject one
raw html element for running the command for processing the wavedrom
diagrams at the onload event.
"""
# Skip for non-html or if javascript is not inlined
if not app.en... | [
"def",
"doctree_resolved",
"(",
"app",
",",
"doctree",
",",
"fromdocname",
")",
":",
"# Skip for non-html or if javascript is not inlined",
"if",
"not",
"app",
".",
"env",
".",
"config",
".",
"wavedrom_html_jsinline",
":",
"return",
"text",
"=",
"\"\"\"\n <script t... | When the document, and all the links are fully resolved, we inject one
raw html element for running the command for processing the wavedrom
diagrams at the onload event. | [
"When",
"the",
"document",
"and",
"all",
"the",
"links",
"are",
"fully",
"resolved",
"we",
"inject",
"one",
"raw",
"html",
"element",
"for",
"running",
"the",
"command",
"for",
"processing",
"the",
"wavedrom",
"diagrams",
"at",
"the",
"onload",
"event",
"."
... | a8cfb4422ba2163453db669348f273af2e72f324 | https://github.com/bavovanachte/sphinx-wavedrom/blob/a8cfb4422ba2163453db669348f273af2e72f324/sphinxcontrib/wavedrom.py#L243-L260 |
53,059 | bavovanachte/sphinx-wavedrom | sphinxcontrib/wavedrom.py | setup | def setup(app):
"""
Setup the extension
"""
app.add_config_value('offline_skin_js_path', None, 'html')
app.add_config_value('offline_wavedrom_js_path', None, 'html')
app.add_config_value('wavedrom_html_jsinline', True, 'html')
app.add_directive('wavedrom', WavedromDirective)
app.connect(... | python | def setup(app):
"""
Setup the extension
"""
app.add_config_value('offline_skin_js_path', None, 'html')
app.add_config_value('offline_wavedrom_js_path', None, 'html')
app.add_config_value('wavedrom_html_jsinline', True, 'html')
app.add_directive('wavedrom', WavedromDirective)
app.connect(... | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"add_config_value",
"(",
"'offline_skin_js_path'",
",",
"None",
",",
"'html'",
")",
"app",
".",
"add_config_value",
"(",
"'offline_wavedrom_js_path'",
",",
"None",
",",
"'html'",
")",
"app",
".",
"add_config_va... | Setup the extension | [
"Setup",
"the",
"extension"
] | a8cfb4422ba2163453db669348f273af2e72f324 | https://github.com/bavovanachte/sphinx-wavedrom/blob/a8cfb4422ba2163453db669348f273af2e72f324/sphinxcontrib/wavedrom.py#L263-L278 |
53,060 | marcinmiklitz/pywindow | pywindow/trajectory.py | make_supercell | def make_supercell(system, matrix, supercell=[1, 1, 1]):
"""
Return a supercell.
This functions takes the input unitcell and creates a supercell of it that
is returned as a new :class:`pywindow.molecular.MolecularSystem`.
Parameters
----------
system : :attr:`pywindow.molecular.MolecularSy... | python | def make_supercell(system, matrix, supercell=[1, 1, 1]):
"""
Return a supercell.
This functions takes the input unitcell and creates a supercell of it that
is returned as a new :class:`pywindow.molecular.MolecularSystem`.
Parameters
----------
system : :attr:`pywindow.molecular.MolecularSy... | [
"def",
"make_supercell",
"(",
"system",
",",
"matrix",
",",
"supercell",
"=",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
":",
"user_supercell",
"=",
"[",
"[",
"1",
",",
"supercell",
"[",
"0",
"]",
"]",
",",
"[",
"1",
",",
"supercell",
"[",
"1",
"]... | Return a supercell.
This functions takes the input unitcell and creates a supercell of it that
is returned as a new :class:`pywindow.molecular.MolecularSystem`.
Parameters
----------
system : :attr:`pywindow.molecular.MolecularSystem.system`
The unit cell for creation of the supercell
... | [
"Return",
"a",
"supercell",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/trajectory.py#L68-L95 |
53,061 | marcinmiklitz/pywindow | pywindow/trajectory.py | DLPOLY.get_frames | def get_frames(self, frames='all', override=False, **kwargs):
"""
Extract frames from the trajectory file.
Depending on the passed parameters a frame, a list of particular
frames, a range of frames (from, to), or all frames can be extracted
with this function.
Parameter... | python | def get_frames(self, frames='all', override=False, **kwargs):
"""
Extract frames from the trajectory file.
Depending on the passed parameters a frame, a list of particular
frames, a range of frames (from, to), or all frames can be extracted
with this function.
Parameter... | [
"def",
"get_frames",
"(",
"self",
",",
"frames",
"=",
"'all'",
",",
"override",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"override",
"is",
"True",
":",
"self",
".",
"frames",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"frames",
",",
"int... | Extract frames from the trajectory file.
Depending on the passed parameters a frame, a list of particular
frames, a range of frames (from, to), or all frames can be extracted
with this function.
Parameters
----------
frames : :class:`int` or :class:`list` or :class:`tou... | [
"Extract",
"frames",
"from",
"the",
"trajectory",
"file",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/trajectory.py#L217-L284 |
53,062 | marcinmiklitz/pywindow | pywindow/trajectory.py | PDB._map_trajectory | def _map_trajectory(self):
""" Return filepath as a class attribute"""
self.trajectory_map = {}
with open(self.filepath, 'r') as trajectory_file:
with closing(
mmap(
trajectory_file.fileno(), 0,
access=ACCESS_READ)) ... | python | def _map_trajectory(self):
""" Return filepath as a class attribute"""
self.trajectory_map = {}
with open(self.filepath, 'r') as trajectory_file:
with closing(
mmap(
trajectory_file.fileno(), 0,
access=ACCESS_READ)) ... | [
"def",
"_map_trajectory",
"(",
"self",
")",
":",
"self",
".",
"trajectory_map",
"=",
"{",
"}",
"with",
"open",
"(",
"self",
".",
"filepath",
",",
"'r'",
")",
"as",
"trajectory_file",
":",
"with",
"closing",
"(",
"mmap",
"(",
"trajectory_file",
".",
"file... | Return filepath as a class attribute | [
"Return",
"filepath",
"as",
"a",
"class",
"attribute"
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/trajectory.py#L1262-L1297 |
53,063 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.full_analysis | def full_analysis(self, ncpus=1, **kwargs):
"""
Perform a full structural analysis of a molecule.
This invokes other methods:
1. :attr:`molecular_weight()`
2. :attr:`calculate_centre_of_mass()`
3. :attr:`calculate_maximum_diameter()`
4. :attr:... | python | def full_analysis(self, ncpus=1, **kwargs):
"""
Perform a full structural analysis of a molecule.
This invokes other methods:
1. :attr:`molecular_weight()`
2. :attr:`calculate_centre_of_mass()`
3. :attr:`calculate_maximum_diameter()`
4. :attr:... | [
"def",
"full_analysis",
"(",
"self",
",",
"ncpus",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"molecular_weight",
"(",
")",
"self",
".",
"calculate_centre_of_mass",
"(",
")",
"self",
".",
"calculate_maximum_diameter",
"(",
")",
"self",
".",
... | Perform a full structural analysis of a molecule.
This invokes other methods:
1. :attr:`molecular_weight()`
2. :attr:`calculate_centre_of_mass()`
3. :attr:`calculate_maximum_diameter()`
4. :attr:`calculate_average_diameter()`
5. :attr:`calculate_... | [
"Perform",
"a",
"full",
"structural",
"analysis",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L337-L386 |
53,064 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_centre_of_mass | def calculate_centre_of_mass(self):
"""
Return the xyz coordinates of the centre of mass of a molecule.
Returns
-------
:class:`numpy.array`
The centre of mass of the molecule.
"""
self.centre_of_mass = center_of_mass(self.elements, self.coordinates)... | python | def calculate_centre_of_mass(self):
"""
Return the xyz coordinates of the centre of mass of a molecule.
Returns
-------
:class:`numpy.array`
The centre of mass of the molecule.
"""
self.centre_of_mass = center_of_mass(self.elements, self.coordinates)... | [
"def",
"calculate_centre_of_mass",
"(",
"self",
")",
":",
"self",
".",
"centre_of_mass",
"=",
"center_of_mass",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
")",
"self",
".",
"properties",
"[",
"'centre_of_mass'",
"]",
"=",
"self",
".",
"ce... | Return the xyz coordinates of the centre of mass of a molecule.
Returns
-------
:class:`numpy.array`
The centre of mass of the molecule. | [
"Return",
"the",
"xyz",
"coordinates",
"of",
"the",
"centre",
"of",
"mass",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L417-L429 |
53,065 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_maximum_diameter | def calculate_maximum_diameter(self):
"""
Return the maximum diamension of a molecule.
Returns
-------
:class:`float`
The maximum dimension of the molecule.
"""
self.maxd_atom_1, self.maxd_atom_2, self.maximum_diameter = max_dim(
self.ele... | python | def calculate_maximum_diameter(self):
"""
Return the maximum diamension of a molecule.
Returns
-------
:class:`float`
The maximum dimension of the molecule.
"""
self.maxd_atom_1, self.maxd_atom_2, self.maximum_diameter = max_dim(
self.ele... | [
"def",
"calculate_maximum_diameter",
"(",
"self",
")",
":",
"self",
".",
"maxd_atom_1",
",",
"self",
".",
"maxd_atom_2",
",",
"self",
".",
"maximum_diameter",
"=",
"max_dim",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
")",
"self",
".",
... | Return the maximum diamension of a molecule.
Returns
-------
:class:`float`
The maximum dimension of the molecule. | [
"Return",
"the",
"maximum",
"diamension",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L431-L448 |
53,066 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_average_diameter | def calculate_average_diameter(self, **kwargs):
"""
Return the average diamension of a molecule.
Returns
-------
:class:`float`
The average dimension of the molecule.
"""
self.average_diameter = find_average_diameter(
self.elements, self.... | python | def calculate_average_diameter(self, **kwargs):
"""
Return the average diamension of a molecule.
Returns
-------
:class:`float`
The average dimension of the molecule.
"""
self.average_diameter = find_average_diameter(
self.elements, self.... | [
"def",
"calculate_average_diameter",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"average_diameter",
"=",
"find_average_diameter",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",... | Return the average diamension of a molecule.
Returns
-------
:class:`float`
The average dimension of the molecule. | [
"Return",
"the",
"average",
"diamension",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L450-L462 |
53,067 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_pore_diameter | def calculate_pore_diameter(self):
"""
Return the intrinsic pore diameter.
Returns
-------
:class:`float`
The intrinsic pore diameter.
"""
self.pore_diameter, self.pore_closest_atom = pore_diameter(
self.elements, self.coordinates)
... | python | def calculate_pore_diameter(self):
"""
Return the intrinsic pore diameter.
Returns
-------
:class:`float`
The intrinsic pore diameter.
"""
self.pore_diameter, self.pore_closest_atom = pore_diameter(
self.elements, self.coordinates)
... | [
"def",
"calculate_pore_diameter",
"(",
"self",
")",
":",
"self",
".",
"pore_diameter",
",",
"self",
".",
"pore_closest_atom",
"=",
"pore_diameter",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
")",
"self",
".",
"properties",
"[",
"'pore_diame... | Return the intrinsic pore diameter.
Returns
-------
:class:`float`
The intrinsic pore diameter. | [
"Return",
"the",
"intrinsic",
"pore",
"diameter",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L464-L480 |
53,068 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_pore_volume | def calculate_pore_volume(self):
"""
Return the intrinsic pore volume.
Returns
-------
:class:`float`
The intrinsic pore volume.
"""
self.pore_volume = sphere_volume(self.calculate_pore_diameter() / 2)
self.properties['pore_volume'] = self.po... | python | def calculate_pore_volume(self):
"""
Return the intrinsic pore volume.
Returns
-------
:class:`float`
The intrinsic pore volume.
"""
self.pore_volume = sphere_volume(self.calculate_pore_diameter() / 2)
self.properties['pore_volume'] = self.po... | [
"def",
"calculate_pore_volume",
"(",
"self",
")",
":",
"self",
".",
"pore_volume",
"=",
"sphere_volume",
"(",
"self",
".",
"calculate_pore_diameter",
"(",
")",
"/",
"2",
")",
"self",
".",
"properties",
"[",
"'pore_volume'",
"]",
"=",
"self",
".",
"pore_volum... | Return the intrinsic pore volume.
Returns
-------
:class:`float`
The intrinsic pore volume. | [
"Return",
"the",
"intrinsic",
"pore",
"volume",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L482-L494 |
53,069 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.calculate_windows | def calculate_windows(self, **kwargs):
"""
Return the diameters of all windows in a molecule.
This function first finds and then measures the diameters of all the
window in the molecule.
Returns
-------
:class:`numpy.array`
An array of windows' diame... | python | def calculate_windows(self, **kwargs):
"""
Return the diameters of all windows in a molecule.
This function first finds and then measures the diameters of all the
window in the molecule.
Returns
-------
:class:`numpy.array`
An array of windows' diame... | [
"def",
"calculate_windows",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"windows",
"=",
"find_windows",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
",",
"*",
"*",
"kwargs",
")",
"if",
"windows",
":",
"self",
".",
"properties",
".... | Return the diameters of all windows in a molecule.
This function first finds and then measures the diameters of all the
window in the molecule.
Returns
-------
:class:`numpy.array`
An array of windows' diameters.
:class:`NoneType`
If no windows ... | [
"Return",
"the",
"diameters",
"of",
"all",
"windows",
"in",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L545-L575 |
53,070 | marcinmiklitz/pywindow | pywindow/molecular.py | Molecule.shift_to_origin | def shift_to_origin(self, **kwargs):
"""
Shift a molecule to Origin.
This function takes the molecule's coordinates and adjust them so that
the centre of mass of the molecule coincides with the origin of the
coordinate system.
Returns
-------
None : :cla... | python | def shift_to_origin(self, **kwargs):
"""
Shift a molecule to Origin.
This function takes the molecule's coordinates and adjust them so that
the centre of mass of the molecule coincides with the origin of the
coordinate system.
Returns
-------
None : :cla... | [
"def",
"shift_to_origin",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"coordinates",
"=",
"shift_com",
"(",
"self",
".",
"elements",
",",
"self",
".",
"coordinates",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_update",
"(",
")"
] | Shift a molecule to Origin.
This function takes the molecule's coordinates and adjust them so that
the centre of mass of the molecule coincides with the origin of the
coordinate system.
Returns
-------
None : :class:`NoneType` | [
"Shift",
"a",
"molecule",
"to",
"Origin",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L577-L591 |
53,071 | marcinmiklitz/pywindow | pywindow/molecular.py | MolecularSystem.rebuild_system | def rebuild_system(self, override=False, **kwargs):
"""
Rebuild molecules in molecular system.
Parameters
----------
override : :class:`bool`, optional (default=False)
If False the rebuild molecular system is returned as a new
:class:`MolecularSystem`, if... | python | def rebuild_system(self, override=False, **kwargs):
"""
Rebuild molecules in molecular system.
Parameters
----------
override : :class:`bool`, optional (default=False)
If False the rebuild molecular system is returned as a new
:class:`MolecularSystem`, if... | [
"def",
"rebuild_system",
"(",
"self",
",",
"override",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# First we create a 3x3x3 supercell with the initial unit cell in the",
"# centre and the 26 unit cell translations around to provide all the",
"# atom positions necessary for the... | Rebuild molecules in molecular system.
Parameters
----------
override : :class:`bool`, optional (default=False)
If False the rebuild molecular system is returned as a new
:class:`MolecularSystem`, if True, the current
:class:`MolecularSystem` is modified. | [
"Rebuild",
"molecules",
"in",
"molecular",
"system",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L880-L920 |
53,072 | marcinmiklitz/pywindow | pywindow/molecular.py | MolecularSystem.swap_atom_keys | def swap_atom_keys(self, swap_dict, dict_key='atom_ids'):
"""
Swap a force field atom id for another user-defined value.
This modified all values in :attr:`MolecularSystem.system['atom_ids']`
that match criteria.
This function can be used to decipher a whole forcefield if an
... | python | def swap_atom_keys(self, swap_dict, dict_key='atom_ids'):
"""
Swap a force field atom id for another user-defined value.
This modified all values in :attr:`MolecularSystem.system['atom_ids']`
that match criteria.
This function can be used to decipher a whole forcefield if an
... | [
"def",
"swap_atom_keys",
"(",
"self",
",",
"swap_dict",
",",
"dict_key",
"=",
"'atom_ids'",
")",
":",
"# Similar situation to the one from decipher_atom_keys function.",
"if",
"'atom_ids'",
"not",
"in",
"self",
".",
"system",
".",
"keys",
"(",
")",
":",
"dict_key",
... | Swap a force field atom id for another user-defined value.
This modified all values in :attr:`MolecularSystem.system['atom_ids']`
that match criteria.
This function can be used to decipher a whole forcefield if an
appropriate dictionary is passed to the function.
Example
... | [
"Swap",
"a",
"force",
"field",
"atom",
"id",
"for",
"another",
"user",
"-",
"defined",
"value",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L922-L961 |
53,073 | marcinmiklitz/pywindow | pywindow/molecular.py | MolecularSystem.decipher_atom_keys | def decipher_atom_keys(self, forcefield='DLF', dict_key='atom_ids'):
"""
Decipher force field atom ids.
This takes all values in :attr:`MolecularSystem.system['atom_ids']`
that match force field type criteria and creates
:attr:`MolecularSystem.system['elements']` with the corres... | python | def decipher_atom_keys(self, forcefield='DLF', dict_key='atom_ids'):
"""
Decipher force field atom ids.
This takes all values in :attr:`MolecularSystem.system['atom_ids']`
that match force field type criteria and creates
:attr:`MolecularSystem.system['elements']` with the corres... | [
"def",
"decipher_atom_keys",
"(",
"self",
",",
"forcefield",
"=",
"'DLF'",
",",
"dict_key",
"=",
"'atom_ids'",
")",
":",
"# In case there is no 'atom_ids' key we try 'elements'. This is for",
"# XYZ and MOL files mostly. But, we keep the dict_key keyword for",
"# someone who would wa... | Decipher force field atom ids.
This takes all values in :attr:`MolecularSystem.system['atom_ids']`
that match force field type criteria and creates
:attr:`MolecularSystem.system['elements']` with the corresponding
periodic table of elements equivalents.
If a forcefield is not s... | [
"Decipher",
"force",
"field",
"atom",
"ids",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L963-L1009 |
53,074 | marcinmiklitz/pywindow | pywindow/molecular.py | MolecularSystem._get_pores | def _get_pores(self, sampling_points):
""" Under development."""
pores = []
for point in sampling_points:
pores.append(
Pore(
self.system['elements'],
self.system['coordinates'],
com=point))
return po... | python | def _get_pores(self, sampling_points):
""" Under development."""
pores = []
for point in sampling_points:
pores.append(
Pore(
self.system['elements'],
self.system['coordinates'],
com=point))
return po... | [
"def",
"_get_pores",
"(",
"self",
",",
"sampling_points",
")",
":",
"pores",
"=",
"[",
"]",
"for",
"point",
"in",
"sampling_points",
":",
"pores",
".",
"append",
"(",
"Pore",
"(",
"self",
".",
"system",
"[",
"'elements'",
"]",
",",
"self",
".",
"system... | Under development. | [
"Under",
"development",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L1052-L1061 |
53,075 | sacrud/sacrud | sacrud/common.py | get_attrname_by_colname | def get_attrname_by_colname(instance, name):
""" Get value from SQLAlchemy instance by column name
:Parameters:
- `instance`: SQLAlchemy model instance.
- `name`: Column name
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarat... | python | def get_attrname_by_colname(instance, name):
""" Get value from SQLAlchemy instance by column name
:Parameters:
- `instance`: SQLAlchemy model instance.
- `name`: Column name
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarat... | [
"def",
"get_attrname_by_colname",
"(",
"instance",
",",
"name",
")",
":",
"for",
"attr",
",",
"column",
"in",
"list",
"(",
"sqlalchemy",
".",
"inspect",
"(",
"instance",
".",
"__class__",
")",
".",
"c",
".",
"items",
"(",
")",
")",
":",
"if",
"column",... | Get value from SQLAlchemy instance by column name
:Parameters:
- `instance`: SQLAlchemy model instance.
- `name`: Column name
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarative_base
>>> Base = declarative_base()
>>> cl... | [
"Get",
"value",
"from",
"SQLAlchemy",
"instance",
"by",
"column",
"name"
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/common.py#L41-L62 |
53,076 | sacrud/sacrud | sacrud/common.py | get_empty_instance | def get_empty_instance(table):
""" Return empty instance of model.
"""
instance_defaults_params = inspect.getargspec(table.__init__).args[1:]
# list like ['name', 'group', 'visible'] to dict with empty
# value as {'name': None, 'group': None, 'visible': None}
init = dict(
list(zip(insta... | python | def get_empty_instance(table):
""" Return empty instance of model.
"""
instance_defaults_params = inspect.getargspec(table.__init__).args[1:]
# list like ['name', 'group', 'visible'] to dict with empty
# value as {'name': None, 'group': None, 'visible': None}
init = dict(
list(zip(insta... | [
"def",
"get_empty_instance",
"(",
"table",
")",
":",
"instance_defaults_params",
"=",
"inspect",
".",
"getargspec",
"(",
"table",
".",
"__init__",
")",
".",
"args",
"[",
"1",
":",
"]",
"# list like ['name', 'group', 'visible'] to dict with empty",
"# value as {'name': N... | Return empty instance of model. | [
"Return",
"empty",
"instance",
"of",
"model",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/common.py#L72-L81 |
53,077 | sacrud/sacrud | sacrud/common.py | get_pk | def get_pk(obj):
""" Return primary key name by model class or instance.
:Parameters:
- `obj`: SQLAlchemy model instance or class.
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarative_base
>>> Base = declarative_base()
>>> cl... | python | def get_pk(obj):
""" Return primary key name by model class or instance.
:Parameters:
- `obj`: SQLAlchemy model instance or class.
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarative_base
>>> Base = declarative_base()
>>> cl... | [
"def",
"get_pk",
"(",
"obj",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"pk_list",
"=",
"sqlalchemy",
".",
"inspect",
"(",
"obj",
")",
".",
"primary_key",
"else",
":",
"pk_list",
"=",
"obj",
".",
"__mapper__",
".",
"primary_key",
... | Return primary key name by model class or instance.
:Parameters:
- `obj`: SQLAlchemy model instance or class.
:Examples:
>>> from sqlalchemy import Column, Integer
>>> from sqlalchemy.ext.declarative import declarative_base
>>> Base = declarative_base()
>>> class User(Base):
... ... | [
"Return",
"primary",
"key",
"name",
"by",
"model",
"class",
"or",
"instance",
"."
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/common.py#L111-L134 |
53,078 | ResilienceTesting/gremlinsdk-python | python/pygremlin/failuregenerator.py | FailureGenerator.clear_rules_from_all_proxies | def clear_rules_from_all_proxies(self):
"""
Clear fault injection rules from all known service proxies.
"""
self._queue = []
if self.debug:
print 'Clearing rules'
for service in self.app.get_services():
for instance in self.app.get_serv... | python | def clear_rules_from_all_proxies(self):
"""
Clear fault injection rules from all known service proxies.
"""
self._queue = []
if self.debug:
print 'Clearing rules'
for service in self.app.get_services():
for instance in self.app.get_serv... | [
"def",
"clear_rules_from_all_proxies",
"(",
"self",
")",
":",
"self",
".",
"_queue",
"=",
"[",
"]",
"if",
"self",
".",
"debug",
":",
"print",
"'Clearing rules'",
"for",
"service",
"in",
"self",
".",
"app",
".",
"get_services",
"(",
")",
":",
"for",
"inst... | Clear fault injection rules from all known service proxies. | [
"Clear",
"fault",
"injection",
"rules",
"from",
"all",
"known",
"service",
"proxies",
"."
] | c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6 | https://github.com/ResilienceTesting/gremlinsdk-python/blob/c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6/python/pygremlin/failuregenerator.py#L126-L139 |
53,079 | ResilienceTesting/gremlinsdk-python | python/pygremlin/failuregenerator.py | FailureGenerator.setup_failure | def setup_failure(self, scenario=None, **args):
"""Add a given failure scenario
@param scenario: string 'delayrequests' or 'crash'
"""
assert scenario is not None and scenario in self.functiondict
self.functiondict[scenario](**args) | python | def setup_failure(self, scenario=None, **args):
"""Add a given failure scenario
@param scenario: string 'delayrequests' or 'crash'
"""
assert scenario is not None and scenario in self.functiondict
self.functiondict[scenario](**args) | [
"def",
"setup_failure",
"(",
"self",
",",
"scenario",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"assert",
"scenario",
"is",
"not",
"None",
"and",
"scenario",
"in",
"self",
".",
"functiondict",
"self",
".",
"functiondict",
"[",
"scenario",
"]",
"(",
... | Add a given failure scenario
@param scenario: string 'delayrequests' or 'crash' | [
"Add",
"a",
"given",
"failure",
"scenario"
] | c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6 | https://github.com/ResilienceTesting/gremlinsdk-python/blob/c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6/python/pygremlin/failuregenerator.py#L288-L293 |
53,080 | ResilienceTesting/gremlinsdk-python | python/pygremlin/failuregenerator.py | FailureGenerator.setup_failures | def setup_failures(self, gremlins):
"""Add gremlins to environment"""
assert isinstance(gremlins, dict) and 'gremlins' in gremlins
for gremlin in gremlins['gremlins']:
self.setup_failure(**gremlin)
self.push_rules() | python | def setup_failures(self, gremlins):
"""Add gremlins to environment"""
assert isinstance(gremlins, dict) and 'gremlins' in gremlins
for gremlin in gremlins['gremlins']:
self.setup_failure(**gremlin)
self.push_rules() | [
"def",
"setup_failures",
"(",
"self",
",",
"gremlins",
")",
":",
"assert",
"isinstance",
"(",
"gremlins",
",",
"dict",
")",
"and",
"'gremlins'",
"in",
"gremlins",
"for",
"gremlin",
"in",
"gremlins",
"[",
"'gremlins'",
"]",
":",
"self",
".",
"setup_failure",
... | Add gremlins to environment | [
"Add",
"gremlins",
"to",
"environment"
] | c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6 | https://github.com/ResilienceTesting/gremlinsdk-python/blob/c5cc439ea1c0d6a98ff88f5604bf739f3c48d1e6/python/pygremlin/failuregenerator.py#L295-L301 |
53,081 | takaakiaoki/ofblockmeshdicthelper | ofblockmeshdicthelper/__init__.py | BlockMeshDict.add_vertex | def add_vertex(self, x, y, z, name):
"""add vertex by coordinate and uniq name
x y z is coordinates of vertex
name is uniq name to refer the vertex
returns Vertex object whici is added.
"""
self.vertices[name] = Vertex(x, y, z, name)
return self.vertices[name] | python | def add_vertex(self, x, y, z, name):
"""add vertex by coordinate and uniq name
x y z is coordinates of vertex
name is uniq name to refer the vertex
returns Vertex object whici is added.
"""
self.vertices[name] = Vertex(x, y, z, name)
return self.vertices[name] | [
"def",
"add_vertex",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
",",
"name",
")",
":",
"self",
".",
"vertices",
"[",
"name",
"]",
"=",
"Vertex",
"(",
"x",
",",
"y",
",",
"z",
",",
"name",
")",
"return",
"self",
".",
"vertices",
"[",
"name",
"... | add vertex by coordinate and uniq name
x y z is coordinates of vertex
name is uniq name to refer the vertex
returns Vertex object whici is added. | [
"add",
"vertex",
"by",
"coordinate",
"and",
"uniq",
"name",
"x",
"y",
"z",
"is",
"coordinates",
"of",
"vertex",
"name",
"is",
"uniq",
"name",
"to",
"refer",
"the",
"vertex",
"returns",
"Vertex",
"object",
"whici",
"is",
"added",
"."
] | df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd | https://github.com/takaakiaoki/ofblockmeshdicthelper/blob/df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd/ofblockmeshdicthelper/__init__.py#L357-L364 |
53,082 | takaakiaoki/ofblockmeshdicthelper | ofblockmeshdicthelper/__init__.py | BlockMeshDict.reduce_vertex | def reduce_vertex(self, name1, *names):
"""treat name1, name2, ... as same point.
name2.alias, name3.alias, ... are merged with name1.alias
the key name2, name3, ... in self.vertices are kept and mapped to
same Vertex instance as name1
"""
v = self.vertices[name1]
... | python | def reduce_vertex(self, name1, *names):
"""treat name1, name2, ... as same point.
name2.alias, name3.alias, ... are merged with name1.alias
the key name2, name3, ... in self.vertices are kept and mapped to
same Vertex instance as name1
"""
v = self.vertices[name1]
... | [
"def",
"reduce_vertex",
"(",
"self",
",",
"name1",
",",
"*",
"names",
")",
":",
"v",
"=",
"self",
".",
"vertices",
"[",
"name1",
"]",
"for",
"n",
"in",
"names",
":",
"w",
"=",
"self",
".",
"vertices",
"[",
"n",
"]",
"v",
".",
"alias",
".",
"upd... | treat name1, name2, ... as same point.
name2.alias, name3.alias, ... are merged with name1.alias
the key name2, name3, ... in self.vertices are kept and mapped to
same Vertex instance as name1 | [
"treat",
"name1",
"name2",
"...",
"as",
"same",
"point",
"."
] | df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd | https://github.com/takaakiaoki/ofblockmeshdicthelper/blob/df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd/ofblockmeshdicthelper/__init__.py#L370-L382 |
53,083 | takaakiaoki/ofblockmeshdicthelper | ofblockmeshdicthelper/__init__.py | BlockMeshDict.merge_vertices | def merge_vertices(self):
"""call reduce_vertex on all vertices with identical values."""
# groupby expects sorted data
sorted_vertices = sorted(list(self.vertices.items()), key=lambda v: hash(v[1]))
groups = []
for k, g in groupby(sorted_vertices, lambda v: hash(v[1])):
... | python | def merge_vertices(self):
"""call reduce_vertex on all vertices with identical values."""
# groupby expects sorted data
sorted_vertices = sorted(list(self.vertices.items()), key=lambda v: hash(v[1]))
groups = []
for k, g in groupby(sorted_vertices, lambda v: hash(v[1])):
... | [
"def",
"merge_vertices",
"(",
"self",
")",
":",
"# groupby expects sorted data",
"sorted_vertices",
"=",
"sorted",
"(",
"list",
"(",
"self",
".",
"vertices",
".",
"items",
"(",
")",
")",
",",
"key",
"=",
"lambda",
"v",
":",
"hash",
"(",
"v",
"[",
"1",
... | call reduce_vertex on all vertices with identical values. | [
"call",
"reduce_vertex",
"on",
"all",
"vertices",
"with",
"identical",
"values",
"."
] | df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd | https://github.com/takaakiaoki/ofblockmeshdicthelper/blob/df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd/ofblockmeshdicthelper/__init__.py#L384-L396 |
53,084 | gdub/python-archive | archive/__init__.py | extract | def extract(path, to_path='', ext='', **kwargs):
"""
Unpack the tar or zip file at the specified path to the directory
specified by to_path.
"""
Archive(path, ext=ext).extract(to_path, **kwargs) | python | def extract(path, to_path='', ext='', **kwargs):
"""
Unpack the tar or zip file at the specified path to the directory
specified by to_path.
"""
Archive(path, ext=ext).extract(to_path, **kwargs) | [
"def",
"extract",
"(",
"path",
",",
"to_path",
"=",
"''",
",",
"ext",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"Archive",
"(",
"path",
",",
"ext",
"=",
"ext",
")",
".",
"extract",
"(",
"to_path",
",",
"*",
"*",
"kwargs",
")"
] | Unpack the tar or zip file at the specified path to the directory
specified by to_path. | [
"Unpack",
"the",
"tar",
"or",
"zip",
"file",
"at",
"the",
"specified",
"path",
"to",
"the",
"directory",
"specified",
"by",
"to_path",
"."
] | 61b9afde21621a8acce964d3336a7fb5d2d07ca6 | https://github.com/gdub/python-archive/blob/61b9afde21621a8acce964d3336a7fb5d2d07ca6/archive/__init__.py#L24-L29 |
53,085 | gdub/python-archive | archive/__init__.py | Archive._archive_cls | def _archive_cls(file, ext=''):
"""
Return the proper Archive implementation class, based on the file type.
"""
cls = None
filename = None
if is_string(file):
filename = file
else:
try:
filename = file.name
excep... | python | def _archive_cls(file, ext=''):
"""
Return the proper Archive implementation class, based on the file type.
"""
cls = None
filename = None
if is_string(file):
filename = file
else:
try:
filename = file.name
excep... | [
"def",
"_archive_cls",
"(",
"file",
",",
"ext",
"=",
"''",
")",
":",
"cls",
"=",
"None",
"filename",
"=",
"None",
"if",
"is_string",
"(",
"file",
")",
":",
"filename",
"=",
"file",
"else",
":",
"try",
":",
"filename",
"=",
"file",
".",
"name",
"exc... | Return the proper Archive implementation class, based on the file type. | [
"Return",
"the",
"proper",
"Archive",
"implementation",
"class",
"based",
"on",
"the",
"file",
"type",
"."
] | 61b9afde21621a8acce964d3336a7fb5d2d07ca6 | https://github.com/gdub/python-archive/blob/61b9afde21621a8acce964d3336a7fb5d2d07ca6/archive/__init__.py#L48-L71 |
53,086 | gdub/python-archive | archive/__init__.py | BaseArchive.check_files | def check_files(self, to_path=None):
"""
Check that all of the files contained in the archive are within the
target directory.
"""
if to_path:
target_path = os.path.normpath(os.path.realpath(to_path))
else:
target_path = os.getcwd()
for fil... | python | def check_files(self, to_path=None):
"""
Check that all of the files contained in the archive are within the
target directory.
"""
if to_path:
target_path = os.path.normpath(os.path.realpath(to_path))
else:
target_path = os.getcwd()
for fil... | [
"def",
"check_files",
"(",
"self",
",",
"to_path",
"=",
"None",
")",
":",
"if",
"to_path",
":",
"target_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"to_path",
")",
")",
"else",
":",
"target_path",
"="... | Check that all of the files contained in the archive are within the
target directory. | [
"Check",
"that",
"all",
"of",
"the",
"files",
"contained",
"in",
"the",
"archive",
"are",
"within",
"the",
"target",
"directory",
"."
] | 61b9afde21621a8acce964d3336a7fb5d2d07ca6 | https://github.com/gdub/python-archive/blob/61b9afde21621a8acce964d3336a7fb5d2d07ca6/archive/__init__.py#L114-L129 |
53,087 | scivision/astrometry_azel | astrometry_azel/io.py | meanstack | def meanstack(infn: Path, Navg: int, ut1: Optional[datetime]=None,
method: str='mean') -> Tuple[np.ndarray, Optional[datetime]]:
infn = Path(infn).expanduser()
# %% parse indicies to load
if isinstance(Navg, slice):
key = Navg
elif isinstance(Navg, int):
key = slice(0, Navg)
... | python | def meanstack(infn: Path, Navg: int, ut1: Optional[datetime]=None,
method: str='mean') -> Tuple[np.ndarray, Optional[datetime]]:
infn = Path(infn).expanduser()
# %% parse indicies to load
if isinstance(Navg, slice):
key = Navg
elif isinstance(Navg, int):
key = slice(0, Navg)
... | [
"def",
"meanstack",
"(",
"infn",
":",
"Path",
",",
"Navg",
":",
"int",
",",
"ut1",
":",
"Optional",
"[",
"datetime",
"]",
"=",
"None",
",",
"method",
":",
"str",
"=",
"'mean'",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"Optional",
"[",
... | some methods handled individually to improve efficiency with huge files | [
"some",
"methods",
"handled",
"individually",
"to",
"improve",
"efficiency",
"with",
"huge",
"files"
] | b7232ff9b53528feae8e9a15b226aaeda4d425d2 | https://github.com/scivision/astrometry_azel/blob/b7232ff9b53528feae8e9a15b226aaeda4d425d2/astrometry_azel/io.py#L43-L75 |
53,088 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient._run_search_request | def _run_search_request(
self, protocol_request, object_name, protocol_response_class):
"""
Runs the specified request at the specified object_name and
instantiates an object of the specified class. We yield each object in
listAttr. If pages of results are present, repeat th... | python | def _run_search_request(
self, protocol_request, object_name, protocol_response_class):
"""
Runs the specified request at the specified object_name and
instantiates an object of the specified class. We yield each object in
listAttr. If pages of results are present, repeat th... | [
"def",
"_run_search_request",
"(",
"self",
",",
"protocol_request",
",",
"object_name",
",",
"protocol_response_class",
")",
":",
"not_done",
"=",
"True",
"while",
"not_done",
":",
"response_object",
"=",
"self",
".",
"_run_search_page_request",
"(",
"protocol_request... | Runs the specified request at the specified object_name and
instantiates an object of the specified class. We yield each object in
listAttr. If pages of results are present, repeat this process
until the pageToken is null. | [
"Runs",
"the",
"specified",
"request",
"at",
"the",
"specified",
"object_name",
"and",
"instantiates",
"an",
"object",
"of",
"the",
"specified",
"class",
".",
"We",
"yield",
"each",
"object",
"in",
"listAttr",
".",
"If",
"pages",
"of",
"results",
"are",
"pre... | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L78-L96 |
53,089 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.list_reference_bases | def list_reference_bases(self, id_, start=0, end=None):
"""
Returns an iterator over the bases from the server in the form
of consecutive strings. This command does not conform to the
patterns of the other search and get requests, and is implemented
differently.
"""
... | python | def list_reference_bases(self, id_, start=0, end=None):
"""
Returns an iterator over the bases from the server in the form
of consecutive strings. This command does not conform to the
patterns of the other search and get requests, and is implemented
differently.
"""
... | [
"def",
"list_reference_bases",
"(",
"self",
",",
"id_",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"request",
"=",
"protocol",
".",
"ListReferenceBasesRequest",
"(",
")",
"request",
".",
"start",
"=",
"pb",
".",
"int",
"(",
"start",
")"... | Returns an iterator over the bases from the server in the form
of consecutive strings. This command does not conform to the
patterns of the other search and get requests, and is implemented
differently. | [
"Returns",
"an",
"iterator",
"over",
"the",
"bases",
"from",
"the",
"server",
"in",
"the",
"form",
"of",
"consecutive",
"strings",
".",
"This",
"command",
"does",
"not",
"conform",
"to",
"the",
"patterns",
"of",
"the",
"other",
"search",
"and",
"get",
"req... | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L105-L125 |
53,090 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_variants | def search_variants(
self, variant_set_id, start=None, end=None, reference_name=None,
call_set_ids=None):
"""
Returns an iterator over the Variants fulfilling the specified
conditions from the specified VariantSet.
:param str variant_set_id: The ID of the
... | python | def search_variants(
self, variant_set_id, start=None, end=None, reference_name=None,
call_set_ids=None):
"""
Returns an iterator over the Variants fulfilling the specified
conditions from the specified VariantSet.
:param str variant_set_id: The ID of the
... | [
"def",
"search_variants",
"(",
"self",
",",
"variant_set_id",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"reference_name",
"=",
"None",
",",
"call_set_ids",
"=",
"None",
")",
":",
"request",
"=",
"protocol",
".",
"SearchVariantsRequest",
"(",
... | Returns an iterator over the Variants fulfilling the specified
conditions from the specified VariantSet.
:param str variant_set_id: The ID of the
:class:`ga4gh.protocol.VariantSet` of interest.
:param int start: Required. The beginning of the window (0-based,
inclusive) ... | [
"Returns",
"an",
"iterator",
"over",
"the",
"Variants",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"VariantSet",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L371-L406 |
53,091 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_variant_annotations | def search_variant_annotations(
self, variant_annotation_set_id, reference_name="",
reference_id="", start=0, end=0, effects=[]):
"""
Returns an iterator over the Variant Annotations fulfilling
the specified conditions from the specified VariantSet.
:param str va... | python | def search_variant_annotations(
self, variant_annotation_set_id, reference_name="",
reference_id="", start=0, end=0, effects=[]):
"""
Returns an iterator over the Variant Annotations fulfilling
the specified conditions from the specified VariantSet.
:param str va... | [
"def",
"search_variant_annotations",
"(",
"self",
",",
"variant_annotation_set_id",
",",
"reference_name",
"=",
"\"\"",
",",
"reference_id",
"=",
"\"\"",
",",
"start",
"=",
"0",
",",
"end",
"=",
"0",
",",
"effects",
"=",
"[",
"]",
")",
":",
"request",
"=",... | Returns an iterator over the Variant Annotations fulfilling
the specified conditions from the specified VariantSet.
:param str variant_annotation_set_id: The ID of the
:class:`ga4gh.protocol.VariantAnnotationSet` of interest.
:param int start: Required. The beginning of the window (... | [
"Returns",
"an",
"iterator",
"over",
"the",
"Variant",
"Annotations",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"VariantSet",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L408-L448 |
53,092 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_features | def search_features(
self, feature_set_id=None, parent_id="", reference_name="",
start=0, end=0, feature_types=[], name="", gene_symbol=""):
"""
Returns the result of running a search_features method
on a request with the passed-in parameters.
:param str feature_... | python | def search_features(
self, feature_set_id=None, parent_id="", reference_name="",
start=0, end=0, feature_types=[], name="", gene_symbol=""):
"""
Returns the result of running a search_features method
on a request with the passed-in parameters.
:param str feature_... | [
"def",
"search_features",
"(",
"self",
",",
"feature_set_id",
"=",
"None",
",",
"parent_id",
"=",
"\"\"",
",",
"reference_name",
"=",
"\"\"",
",",
"start",
"=",
"0",
",",
"end",
"=",
"0",
",",
"feature_types",
"=",
"[",
"]",
",",
"name",
"=",
"\"\"",
... | Returns the result of running a search_features method
on a request with the passed-in parameters.
:param str feature_set_id: ID of the feature Set being searched
:param str parent_id: ID (optional) of the parent feature
:param str reference_name: name of the reference to search
... | [
"Returns",
"the",
"result",
"of",
"running",
"a",
"search_features",
"method",
"on",
"a",
"request",
"with",
"the",
"passed",
"-",
"in",
"parameters",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L450-L481 |
53,093 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_continuous | def search_continuous(
self, continuous_set_id=None, reference_name="", start=0, end=0):
"""
Returns the result of running a search_continuous method
on a request with the passed-in parameters.
:param str continuous_set_id: ID of the ContinuousSet being searched
:par... | python | def search_continuous(
self, continuous_set_id=None, reference_name="", start=0, end=0):
"""
Returns the result of running a search_continuous method
on a request with the passed-in parameters.
:param str continuous_set_id: ID of the ContinuousSet being searched
:par... | [
"def",
"search_continuous",
"(",
"self",
",",
"continuous_set_id",
"=",
"None",
",",
"reference_name",
"=",
"\"\"",
",",
"start",
"=",
"0",
",",
"end",
"=",
"0",
")",
":",
"request",
"=",
"protocol",
".",
"SearchContinuousRequest",
"(",
")",
"request",
"."... | Returns the result of running a search_continuous method
on a request with the passed-in parameters.
:param str continuous_set_id: ID of the ContinuousSet being searched
:param str reference_name: name of the reference to search
(ex: "chr1")
:param int start: search start po... | [
"Returns",
"the",
"result",
"of",
"running",
"a",
"search_continuous",
"method",
"on",
"a",
"request",
"with",
"the",
"passed",
"-",
"in",
"parameters",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L483-L505 |
53,094 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_datasets | def search_datasets(self):
"""
Returns an iterator over the Datasets on the server.
:return: An iterator over the :class:`ga4gh.protocol.Dataset`
objects on the server.
"""
request = protocol.SearchDatasetsRequest()
request.page_size = pb.int(self._page_size)... | python | def search_datasets(self):
"""
Returns an iterator over the Datasets on the server.
:return: An iterator over the :class:`ga4gh.protocol.Dataset`
objects on the server.
"""
request = protocol.SearchDatasetsRequest()
request.page_size = pb.int(self._page_size)... | [
"def",
"search_datasets",
"(",
"self",
")",
":",
"request",
"=",
"protocol",
".",
"SearchDatasetsRequest",
"(",
")",
"request",
".",
"page_size",
"=",
"pb",
".",
"int",
"(",
"self",
".",
"_page_size",
")",
"return",
"self",
".",
"_run_search_request",
"(",
... | Returns an iterator over the Datasets on the server.
:return: An iterator over the :class:`ga4gh.protocol.Dataset`
objects on the server. | [
"Returns",
"an",
"iterator",
"over",
"the",
"Datasets",
"on",
"the",
"server",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L507-L517 |
53,095 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_variant_sets | def search_variant_sets(self, dataset_id):
"""
Returns an iterator over the VariantSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the :class:`ga4gh.protocol.Dataset`
of interest.
:return: An iterator over the :cl... | python | def search_variant_sets(self, dataset_id):
"""
Returns an iterator over the VariantSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the :class:`ga4gh.protocol.Dataset`
of interest.
:return: An iterator over the :cl... | [
"def",
"search_variant_sets",
"(",
"self",
",",
"dataset_id",
")",
":",
"request",
"=",
"protocol",
".",
"SearchVariantSetsRequest",
"(",
")",
"request",
".",
"dataset_id",
"=",
"dataset_id",
"request",
".",
"page_size",
"=",
"pb",
".",
"int",
"(",
"self",
"... | Returns an iterator over the VariantSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the :class:`ga4gh.protocol.Dataset`
of interest.
:return: An iterator over the :class:`ga4gh.protocol.VariantSet`
objects defined by ... | [
"Returns",
"an",
"iterator",
"over",
"the",
"VariantSets",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"Dataset",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L519-L533 |
53,096 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_variant_annotation_sets | def search_variant_annotation_sets(self, variant_set_id):
"""
Returns an iterator over the Annotation Sets fulfilling the specified
conditions from the specified variant set.
:param str variant_set_id: The ID of the
:class:`ga4gh.protocol.VariantSet` of interest.
:re... | python | def search_variant_annotation_sets(self, variant_set_id):
"""
Returns an iterator over the Annotation Sets fulfilling the specified
conditions from the specified variant set.
:param str variant_set_id: The ID of the
:class:`ga4gh.protocol.VariantSet` of interest.
:re... | [
"def",
"search_variant_annotation_sets",
"(",
"self",
",",
"variant_set_id",
")",
":",
"request",
"=",
"protocol",
".",
"SearchVariantAnnotationSetsRequest",
"(",
")",
"request",
".",
"variant_set_id",
"=",
"variant_set_id",
"request",
".",
"page_size",
"=",
"pb",
"... | Returns an iterator over the Annotation Sets fulfilling the specified
conditions from the specified variant set.
:param str variant_set_id: The ID of the
:class:`ga4gh.protocol.VariantSet` of interest.
:return: An iterator over the :class:`ga4gh.protocol.AnnotationSet`
o... | [
"Returns",
"an",
"iterator",
"over",
"the",
"Annotation",
"Sets",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"variant",
"set",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L535-L550 |
53,097 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_feature_sets | def search_feature_sets(self, dataset_id):
"""
Returns an iterator over the FeatureSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over the :cl... | python | def search_feature_sets(self, dataset_id):
"""
Returns an iterator over the FeatureSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over the :cl... | [
"def",
"search_feature_sets",
"(",
"self",
",",
"dataset_id",
")",
":",
"request",
"=",
"protocol",
".",
"SearchFeatureSetsRequest",
"(",
")",
"request",
".",
"dataset_id",
"=",
"dataset_id",
"request",
".",
"page_size",
"=",
"pb",
".",
"int",
"(",
"self",
"... | Returns an iterator over the FeatureSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over the :class:`ga4gh.protocol.FeatureSet`
objects defined by ... | [
"Returns",
"an",
"iterator",
"over",
"the",
"FeatureSets",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"Dataset",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L552-L566 |
53,098 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_continuous_sets | def search_continuous_sets(self, dataset_id):
"""
Returns an iterator over the ContinuousSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over t... | python | def search_continuous_sets(self, dataset_id):
"""
Returns an iterator over the ContinuousSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over t... | [
"def",
"search_continuous_sets",
"(",
"self",
",",
"dataset_id",
")",
":",
"request",
"=",
"protocol",
".",
"SearchContinuousSetsRequest",
"(",
")",
"request",
".",
"dataset_id",
"=",
"dataset_id",
"request",
".",
"page_size",
"=",
"pb",
".",
"int",
"(",
"self... | Returns an iterator over the ContinuousSets fulfilling the specified
conditions from the specified Dataset.
:param str dataset_id: The ID of the
:class:`ga4gh.protocol.Dataset` of interest.
:return: An iterator over the :class:`ga4gh.protocol.ContinuousSet`
objects defin... | [
"Returns",
"an",
"iterator",
"over",
"the",
"ContinuousSets",
"fulfilling",
"the",
"specified",
"conditions",
"from",
"the",
"specified",
"Dataset",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L568-L582 |
53,099 | ga4gh/ga4gh-client | ga4gh/client/client.py | AbstractClient.search_reference_sets | def search_reference_sets(
self, accession=None, md5checksum=None, assembly_id=None):
"""
Returns an iterator over the ReferenceSets fulfilling the specified
conditions.
:param str accession: If not null, return the reference sets for which
the `accession` matche... | python | def search_reference_sets(
self, accession=None, md5checksum=None, assembly_id=None):
"""
Returns an iterator over the ReferenceSets fulfilling the specified
conditions.
:param str accession: If not null, return the reference sets for which
the `accession` matche... | [
"def",
"search_reference_sets",
"(",
"self",
",",
"accession",
"=",
"None",
",",
"md5checksum",
"=",
"None",
",",
"assembly_id",
"=",
"None",
")",
":",
"request",
"=",
"protocol",
".",
"SearchReferenceSetsRequest",
"(",
")",
"request",
".",
"accession",
"=",
... | Returns an iterator over the ReferenceSets fulfilling the specified
conditions.
:param str accession: If not null, return the reference sets for which
the `accession` matches this string (case-sensitive, exact match).
:param str md5checksum: If not null, return the reference sets fo... | [
"Returns",
"an",
"iterator",
"over",
"the",
"ReferenceSets",
"fulfilling",
"the",
"specified",
"conditions",
"."
] | d23b00b89112ef0930d45ee75aa3c6de3db615c5 | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L584-L608 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.