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
44,300
symphonyoss/python-symphony
symphony/Pod/streams.py
Streams.promote_owner
def promote_owner(self, stream_id, user_id): ''' promote user to owner in stream ''' req_hook = 'pod/v1/room/' + stream_id + '/membership/promoteOwner' req_args = '{ "id": %s }' % user_id status_code, response = self.__rest__.POST_query(req_hook, req_args) self.logger.debug('%s: ...
python
def promote_owner(self, stream_id, user_id): ''' promote user to owner in stream ''' req_hook = 'pod/v1/room/' + stream_id + '/membership/promoteOwner' req_args = '{ "id": %s }' % user_id status_code, response = self.__rest__.POST_query(req_hook, req_args) self.logger.debug('%s: ...
[ "def", "promote_owner", "(", "self", ",", "stream_id", ",", "user_id", ")", ":", "req_hook", "=", "'pod/v1/room/'", "+", "stream_id", "+", "'/membership/promoteOwner'", "req_args", "=", "'{ \"id\": %s }'", "%", "user_id", "status_code", ",", "response", "=", "self...
promote user to owner in stream
[ "promote", "user", "to", "owner", "in", "stream" ]
b939f35fbda461183ec0c01790c754f89a295be0
https://github.com/symphonyoss/python-symphony/blob/b939f35fbda461183ec0c01790c754f89a295be0/symphony/Pod/streams.py#L87-L93
44,301
symphonyoss/python-symphony
symphony/Pod/streams.py
Streams.list_streams
def list_streams(self, types=[], inactive=False): ''' list user streams ''' req_hook = 'pod/v1/streams/list' json_query = { "streamTypes": types, "includeInactiveStreams": inactive } req_args = json.dumps(json_query) ...
python
def list_streams(self, types=[], inactive=False): ''' list user streams ''' req_hook = 'pod/v1/streams/list' json_query = { "streamTypes": types, "includeInactiveStreams": inactive } req_args = json.dumps(json_query) ...
[ "def", "list_streams", "(", "self", ",", "types", "=", "[", "]", ",", "inactive", "=", "False", ")", ":", "req_hook", "=", "'pod/v1/streams/list'", "json_query", "=", "{", "\"streamTypes\"", ":", "types", ",", "\"includeInactiveStreams\"", ":", "inactive", "}"...
list user streams
[ "list", "user", "streams" ]
b939f35fbda461183ec0c01790c754f89a295be0
https://github.com/symphonyoss/python-symphony/blob/b939f35fbda461183ec0c01790c754f89a295be0/symphony/Pod/streams.py#L117-L127
44,302
capless/python-jose-cryptodome
jose/jwt.py
get_unverified_claims
def get_unverified_claims(token): """Returns the decoded claims without verification of any kind. Args: token (str): A signed JWT to decode the headers from. Returns: dict: The dict representation of the token claims. Raises: JWTError: If there is an exception decoding the tok...
python
def get_unverified_claims(token): """Returns the decoded claims without verification of any kind. Args: token (str): A signed JWT to decode the headers from. Returns: dict: The dict representation of the token claims. Raises: JWTError: If there is an exception decoding the tok...
[ "def", "get_unverified_claims", "(", "token", ")", ":", "try", ":", "claims", "=", "jws", ".", "get_unverified_claims", "(", "token", ")", "except", ":", "raise", "JWTError", "(", "'Error decoding token claims.'", ")", "try", ":", "claims", "=", "json", ".", ...
Returns the decoded claims without verification of any kind. Args: token (str): A signed JWT to decode the headers from. Returns: dict: The dict representation of the token claims. Raises: JWTError: If there is an exception decoding the token.
[ "Returns", "the", "decoded", "claims", "without", "verification", "of", "any", "kind", "." ]
a169236e2380cff7f1380bbe8eba70cda7393e28
https://github.com/capless/python-jose-cryptodome/blob/a169236e2380cff7f1380bbe8eba70cda7393e28/jose/jwt.py#L193-L218
44,303
capless/python-jose-cryptodome
jose/jwt.py
_validate_at_hash
def _validate_at_hash(claims, access_token, algorithm): """ Validates that the 'at_hash' parameter included in the claims matches with the access_token returned alongside the id token as part of the authorization_code flow. Args: claims (dict): The claims dictionary to validate. acc...
python
def _validate_at_hash(claims, access_token, algorithm): """ Validates that the 'at_hash' parameter included in the claims matches with the access_token returned alongside the id token as part of the authorization_code flow. Args: claims (dict): The claims dictionary to validate. acc...
[ "def", "_validate_at_hash", "(", "claims", ",", "access_token", ",", "algorithm", ")", ":", "if", "'at_hash'", "not", "in", "claims", "and", "not", "access_token", ":", "return", "elif", "'at_hash'", "in", "claims", "and", "not", "access_token", ":", "msg", ...
Validates that the 'at_hash' parameter included in the claims matches with the access_token returned alongside the id token as part of the authorization_code flow. Args: claims (dict): The claims dictionary to validate. access_token (str): The access token returned by the OpenID Provider. ...
[ "Validates", "that", "the", "at_hash", "parameter", "included", "in", "the", "claims", "matches", "with", "the", "access_token", "returned", "alongside", "the", "id", "token", "as", "part", "of", "the", "authorization_code", "flow", "." ]
a169236e2380cff7f1380bbe8eba70cda7393e28
https://github.com/capless/python-jose-cryptodome/blob/a169236e2380cff7f1380bbe8eba70cda7393e28/jose/jwt.py#L407-L436
44,304
symphonyoss/python-symphony
symphony/Auth/__init__.py
Auth.get_session_token
def get_session_token(self): ''' get session token ''' # HTTP POST query to session authenticate API try: response = requests.post(self.__session_url__ + 'sessionauth/v1/authenticate', cert=(self.__crt__, self.__key__), verify=True) except...
python
def get_session_token(self): ''' get session token ''' # HTTP POST query to session authenticate API try: response = requests.post(self.__session_url__ + 'sessionauth/v1/authenticate', cert=(self.__crt__, self.__key__), verify=True) except...
[ "def", "get_session_token", "(", "self", ")", ":", "# HTTP POST query to session authenticate API", "try", ":", "response", "=", "requests", ".", "post", "(", "self", ".", "__session_url__", "+", "'sessionauth/v1/authenticate'", ",", "cert", "=", "(", "self", ".", ...
get session token
[ "get", "session", "token" ]
b939f35fbda461183ec0c01790c754f89a295be0
https://github.com/symphonyoss/python-symphony/blob/b939f35fbda461183ec0c01790c754f89a295be0/symphony/Auth/__init__.py#L27-L46
44,305
CalebBell/ht
ht/radiation.py
solar_spectrum
def solar_spectrum(model='SOLAR-ISS'): r'''Returns the solar spectrum of the sun according to the specified model. Only the 'SOLAR-ISS' model is supported. Parameters ---------- model : str, optional The model to use; 'SOLAR-ISS' is the only model available, [-] Returns ------- ...
python
def solar_spectrum(model='SOLAR-ISS'): r'''Returns the solar spectrum of the sun according to the specified model. Only the 'SOLAR-ISS' model is supported. Parameters ---------- model : str, optional The model to use; 'SOLAR-ISS' is the only model available, [-] Returns ------- ...
[ "def", "solar_spectrum", "(", "model", "=", "'SOLAR-ISS'", ")", ":", "if", "model", "==", "'SOLAR-ISS'", ":", "pth", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "'solar_iss_2018_spectrum.dat'", ")", "data", "=", "np", ".", "loadtxt", "(", "p...
r'''Returns the solar spectrum of the sun according to the specified model. Only the 'SOLAR-ISS' model is supported. Parameters ---------- model : str, optional The model to use; 'SOLAR-ISS' is the only model available, [-] Returns ------- wavelengths : ndarray The waveleng...
[ "r", "Returns", "the", "solar", "spectrum", "of", "the", "sun", "according", "to", "the", "specified", "model", ".", "Only", "the", "SOLAR", "-", "ISS", "model", "is", "supported", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/radiation.py#L183-L258
44,306
CalebBell/ht
ht/boiling_nucleic.py
qmax_boiling
def qmax_boiling(rhol=None, rhog=None, sigma=None, Hvap=None, D=None, P=None, Pc=None, Method=None, AvailableMethods=False): r'''This function handles the calculation of nucleate boiling critical heat flux and chooses the best method for performing the calculation. Preferred methods a...
python
def qmax_boiling(rhol=None, rhog=None, sigma=None, Hvap=None, D=None, P=None, Pc=None, Method=None, AvailableMethods=False): r'''This function handles the calculation of nucleate boiling critical heat flux and chooses the best method for performing the calculation. Preferred methods a...
[ "def", "qmax_boiling", "(", "rhol", "=", "None", ",", "rhog", "=", "None", ",", "sigma", "=", "None", ",", "Hvap", "=", "None", ",", "D", "=", "None", ",", "P", "=", "None", ",", "Pc", "=", "None", ",", "Method", "=", "None", ",", "AvailableMetho...
r'''This function handles the calculation of nucleate boiling critical heat flux and chooses the best method for performing the calculation. Preferred methods are 'Serth-HEDH' when a tube diameter is specified, and 'Zuber' otherwise. Parameters ---------- rhol : float, optional Den...
[ "r", "This", "function", "handles", "the", "calculation", "of", "nucleate", "boiling", "critical", "heat", "flux", "and", "chooses", "the", "best", "method", "for", "performing", "the", "calculation", ".", "Preferred", "methods", "are", "Serth", "-", "HEDH", "...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/boiling_nucleic.py#L1165-L1238
44,307
CalebBell/ht
ht/conv_free_immersed.py
Nu_vertical_cylinder
def Nu_vertical_cylinder(Pr, Gr, L=None, D=None, Method=None, AvailableMethods=False): r'''This function handles choosing which vertical cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the co...
python
def Nu_vertical_cylinder(Pr, Gr, L=None, D=None, Method=None, AvailableMethods=False): r'''This function handles choosing which vertical cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the co...
[ "def", "Nu_vertical_cylinder", "(", "Pr", ",", "Gr", ",", "L", "=", "None", ",", "D", "=", "None", ",", "Method", "=", "None", ",", "AvailableMethods", "=", "False", ")", ":", "def", "list_methods", "(", ")", ":", "methods", "=", "[", "]", "for", "...
r'''This function handles choosing which vertical cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the correlation to use if none is provided; returns None if insufficient information is provided. Preferred funct...
[ "r", "This", "function", "handles", "choosing", "which", "vertical", "cylinder", "free", "convection", "correlation", "is", "used", ".", "Generally", "this", "is", "used", "by", "a", "helper", "class", "but", "can", "be", "used", "directly", ".", "Will", "au...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_free_immersed.py#L774-L841
44,308
CalebBell/ht
ht/conv_free_immersed.py
Nu_horizontal_cylinder
def Nu_horizontal_cylinder(Pr, Gr, Method=None, AvailableMethods=False): r'''This function handles choosing which horizontal cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the correlation to use if none is provi...
python
def Nu_horizontal_cylinder(Pr, Gr, Method=None, AvailableMethods=False): r'''This function handles choosing which horizontal cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the correlation to use if none is provi...
[ "def", "Nu_horizontal_cylinder", "(", "Pr", ",", "Gr", ",", "Method", "=", "None", ",", "AvailableMethods", "=", "False", ")", ":", "def", "list_methods", "(", ")", ":", "methods", "=", "[", "]", "for", "key", ",", "values", "in", "horizontal_cylinder_corr...
r'''This function handles choosing which horizontal cylinder free convection correlation is used. Generally this is used by a helper class, but can be used directly. Will automatically select the correlation to use if none is provided; returns None if insufficient information is provided. Prefered func...
[ "r", "This", "function", "handles", "choosing", "which", "horizontal", "cylinder", "free", "convection", "correlation", "is", "used", ".", "Generally", "this", "is", "used", "by", "a", "helper", "class", "but", "can", "be", "used", "directly", ".", "Will", "...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_free_immersed.py#L1035-L1090
44,309
CalebBell/ht
ht/hx.py
calc_Cmin
def calc_Cmin(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate for the minimum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{min} = \min(C_c, C_h) Parameters ---------- mh : float...
python
def calc_Cmin(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate for the minimum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{min} = \min(C_c, C_h) Parameters ---------- mh : float...
[ "def", "calc_Cmin", "(", "mh", ",", "mc", ",", "Cph", ",", "Cpc", ")", ":", "Ch", "=", "mh", "*", "Cph", "Cc", "=", "mc", "*", "Cpc", "return", "min", "(", "Ch", ",", "Cc", ")" ]
r'''Returns the heat capacity rate for the minimum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{min} = \min(C_c, C_h) Parameters ---------- mh : float Mass flow rate of hot stream...
[ "r", "Returns", "the", "heat", "capacity", "rate", "for", "the", "minimum", "stream", "having", "flows", "mh", "and", "mc", "with", "averaged", "heat", "capacities", "Cph", "and", "Cpc", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L557-L604
44,310
CalebBell/ht
ht/hx.py
calc_Cmax
def calc_Cmax(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate for the maximum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{max} = \max(C_c, C_h) Parameters ---------- mh : float...
python
def calc_Cmax(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate for the maximum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{max} = \max(C_c, C_h) Parameters ---------- mh : float...
[ "def", "calc_Cmax", "(", "mh", ",", "mc", ",", "Cph", ",", "Cpc", ")", ":", "Ch", "=", "mh", "*", "Cph", "Cc", "=", "mc", "*", "Cpc", "return", "max", "(", "Ch", ",", "Cc", ")" ]
r'''Returns the heat capacity rate for the maximum stream having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_c = m_cC_{p,c} C_h = m_h C_{p,h} C_{max} = \max(C_c, C_h) Parameters ---------- mh : float Mass flow rate of hot stream...
[ "r", "Returns", "the", "heat", "capacity", "rate", "for", "the", "maximum", "stream", "having", "flows", "mh", "and", "mc", "with", "averaged", "heat", "capacities", "Cph", "and", "Cpc", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L607-L654
44,311
CalebBell/ht
ht/hx.py
calc_Cr
def calc_Cr(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate ratio for a heat exchanger having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_r=C^*=\frac{C_{min}}{C_{max}} Parameters ---------- mh : float Mass flow rate of hot stream, [kg/s...
python
def calc_Cr(mh, mc, Cph, Cpc): r'''Returns the heat capacity rate ratio for a heat exchanger having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_r=C^*=\frac{C_{min}}{C_{max}} Parameters ---------- mh : float Mass flow rate of hot stream, [kg/s...
[ "def", "calc_Cr", "(", "mh", ",", "mc", ",", "Cph", ",", "Cpc", ")", ":", "Ch", "=", "mh", "*", "Cph", "Cc", "=", "mc", "*", "Cpc", "Cmin", "=", "min", "(", "Ch", ",", "Cc", ")", "Cmax", "=", "max", "(", "Ch", ",", "Cc", ")", "return", "C...
r'''Returns the heat capacity rate ratio for a heat exchanger having flows `mh` and `mc`, with averaged heat capacities `Cph` and `Cpc`. .. math:: C_r=C^*=\frac{C_{min}}{C_{max}} Parameters ---------- mh : float Mass flow rate of hot stream, [kg/s] mc : float Mass flow ...
[ "r", "Returns", "the", "heat", "capacity", "rate", "ratio", "for", "a", "heat", "exchanger", "having", "flows", "mh", "and", "mc", "with", "averaged", "heat", "capacities", "Cph", "and", "Cpc", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L657-L703
44,312
CalebBell/ht
ht/hx.py
Pc
def Pc(x, y): r'''Basic helper calculator which accepts a transformed R1 and NTU1 as inputs for a common term used in the calculation of the P-NTU method for plate exchangers. Returns a value which is normally used in other calculations before the actual P1 is calculated. Nominally used in c...
python
def Pc(x, y): r'''Basic helper calculator which accepts a transformed R1 and NTU1 as inputs for a common term used in the calculation of the P-NTU method for plate exchangers. Returns a value which is normally used in other calculations before the actual P1 is calculated. Nominally used in c...
[ "def", "Pc", "(", "x", ",", "y", ")", ":", "try", ":", "term", "=", "exp", "(", "-", "x", "*", "(", "1.", "-", "y", ")", ")", "return", "(", "1.", "-", "term", ")", "/", "(", "1.", "-", "y", "*", "term", ")", "except", "ZeroDivisionError", ...
r'''Basic helper calculator which accepts a transformed R1 and NTU1 as inputs for a common term used in the calculation of the P-NTU method for plate exchangers. Returns a value which is normally used in other calculations before the actual P1 is calculated. Nominally used in counterflow calcula...
[ "r", "Basic", "helper", "calculator", "which", "accepts", "a", "transformed", "R1", "and", "NTU1", "as", "inputs", "for", "a", "common", "term", "used", "in", "the", "calculation", "of", "the", "P", "-", "NTU", "method", "for", "plate", "exchangers", ".", ...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L827-L872
44,313
CalebBell/ht
ht/hx.py
_NTU_from_P_solver
def _NTU_from_P_solver(P1, R1, NTU_min, NTU_max, function, **kwargs): '''Private function to solve the P-NTU method backwards, given the function to use, the upper and lower NTU bounds for consideration, and the desired P1 and R1 values. ''' P1_max = _NTU_from_P_objective(NTU_max, R1, 0, function, *...
python
def _NTU_from_P_solver(P1, R1, NTU_min, NTU_max, function, **kwargs): '''Private function to solve the P-NTU method backwards, given the function to use, the upper and lower NTU bounds for consideration, and the desired P1 and R1 values. ''' P1_max = _NTU_from_P_objective(NTU_max, R1, 0, function, *...
[ "def", "_NTU_from_P_solver", "(", "P1", ",", "R1", ",", "NTU_min", ",", "NTU_max", ",", "function", ",", "*", "*", "kwargs", ")", ":", "P1_max", "=", "_NTU_from_P_objective", "(", "NTU_max", ",", "R1", ",", "0", ",", "function", ",", "*", "*", "kwargs"...
Private function to solve the P-NTU method backwards, given the function to use, the upper and lower NTU bounds for consideration, and the desired P1 and R1 values.
[ "Private", "function", "to", "solve", "the", "P", "-", "NTU", "method", "backwards", "given", "the", "function", "to", "use", "the", "upper", "and", "lower", "NTU", "bounds", "for", "consideration", "and", "the", "desired", "P1", "and", "R1", "values", "."...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L2964-L2977
44,314
CalebBell/ht
ht/hx.py
_NTU_max_for_P_solver
def _NTU_max_for_P_solver(data, R1): '''Private function to calculate the upper bound on the NTU1 value in the P-NTU method. This value is calculated via a pade approximation obtained on the result of a global minimizer which calculated the maximum P1 at a given R1 from ~1E-7 to approximately 100. This ...
python
def _NTU_max_for_P_solver(data, R1): '''Private function to calculate the upper bound on the NTU1 value in the P-NTU method. This value is calculated via a pade approximation obtained on the result of a global minimizer which calculated the maximum P1 at a given R1 from ~1E-7 to approximately 100. This ...
[ "def", "_NTU_max_for_P_solver", "(", "data", ",", "R1", ")", ":", "offset_max", "=", "data", "[", "'offset'", "]", "[", "-", "1", "]", "for", "offset", ",", "p", ",", "q", "in", "zip", "(", "data", "[", "'offset'", "]", ",", "data", "[", "'p'", "...
Private function to calculate the upper bound on the NTU1 value in the P-NTU method. This value is calculated via a pade approximation obtained on the result of a global minimizer which calculated the maximum P1 at a given R1 from ~1E-7 to approximately 100. This should suffice for engineering applicat...
[ "Private", "function", "to", "calculate", "the", "upper", "bound", "on", "the", "NTU1", "value", "in", "the", "P", "-", "NTU", "method", ".", "This", "value", "is", "calculated", "via", "a", "pade", "approximation", "obtained", "on", "the", "result", "of",...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L2980-L2991
44,315
CalebBell/ht
ht/hx.py
Ntubes_VDI
def Ntubes_VDI(DBundle=None, Ntp=None, Do=None, pitch=None, angle=30.): r'''A rough equation presented in the VDI Heat Atlas for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Parameters ---------- DBundle : float Ou...
python
def Ntubes_VDI(DBundle=None, Ntp=None, Do=None, pitch=None, angle=30.): r'''A rough equation presented in the VDI Heat Atlas for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Parameters ---------- DBundle : float Ou...
[ "def", "Ntubes_VDI", "(", "DBundle", "=", "None", ",", "Ntp", "=", "None", ",", "Do", "=", "None", ",", "pitch", "=", "None", ",", "angle", "=", "30.", ")", ":", "if", "Ntp", "==", "1", ":", "f2", "=", "0.", "elif", "Ntp", "==", "2", ":", "f2...
r'''A rough equation presented in the VDI Heat Atlas for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Parameters ---------- DBundle : float Outer diameter of tube bundle, [m] Ntp : float Number of tube pass...
[ "r", "A", "rough", "equation", "presented", "in", "the", "VDI", "Heat", "Atlas", "for", "estimating", "the", "number", "of", "tubes", "in", "a", "tube", "bundle", "of", "differing", "geometries", "and", "tube", "sizes", ".", "No", "accuracy", "estimation", ...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L6001-L6064
44,316
CalebBell/ht
ht/hx.py
D_for_Ntubes_VDI
def D_for_Ntubes_VDI(N, Ntp, Do, pitch, angle=30): r'''A rough equation presented in the VDI Heat Atlas for estimating the size of a tube bundle from a given number of tubes, number of tube passes, outer tube diameter, pitch, and arrangement. No accuracy estimation given. .. math:: OTL = \s...
python
def D_for_Ntubes_VDI(N, Ntp, Do, pitch, angle=30): r'''A rough equation presented in the VDI Heat Atlas for estimating the size of a tube bundle from a given number of tubes, number of tube passes, outer tube diameter, pitch, and arrangement. No accuracy estimation given. .. math:: OTL = \s...
[ "def", "D_for_Ntubes_VDI", "(", "N", ",", "Ntp", ",", "Do", ",", "pitch", ",", "angle", "=", "30", ")", ":", "if", "Ntp", "==", "1", ":", "f2", "=", "0.", "elif", "Ntp", "==", "2", ":", "f2", "=", "22.", "elif", "Ntp", "==", "4", ":", "f2", ...
r'''A rough equation presented in the VDI Heat Atlas for estimating the size of a tube bundle from a given number of tubes, number of tube passes, outer tube diameter, pitch, and arrangement. No accuracy estimation given. .. math:: OTL = \sqrt{f_1 z t^2 + f_2 t \sqrt{z} - d_o} Parameters ...
[ "r", "A", "rough", "equation", "presented", "in", "the", "VDI", "Heat", "Atlas", "for", "estimating", "the", "size", "of", "a", "tube", "bundle", "from", "a", "given", "number", "of", "tubes", "number", "of", "tube", "passes", "outer", "tube", "diameter", ...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L6067-L6132
44,317
CalebBell/ht
ht/hx.py
Ntubes_HEDH
def Ntubes_HEDH(DBundle=None, Do=None, pitch=None, angle=30): r'''A rough equation presented in the HEDH for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Only 1 pass is supported. .. math:: N = \frac{0.78(D_{bundle} - D_o)...
python
def Ntubes_HEDH(DBundle=None, Do=None, pitch=None, angle=30): r'''A rough equation presented in the HEDH for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Only 1 pass is supported. .. math:: N = \frac{0.78(D_{bundle} - D_o)...
[ "def", "Ntubes_HEDH", "(", "DBundle", "=", "None", ",", "Do", "=", "None", ",", "pitch", "=", "None", ",", "angle", "=", "30", ")", ":", "if", "angle", "==", "30", "or", "angle", "==", "60", ":", "C1", "=", "13", "/", "15.", "elif", "angle", "=...
r'''A rough equation presented in the HEDH for estimating the number of tubes in a tube bundle of differing geometries and tube sizes. No accuracy estimation given. Only 1 pass is supported. .. math:: N = \frac{0.78(D_{bundle} - D_o)^2}{C_1(\text{pitch})^2} C1 = 0.866 for 30° and 60° l...
[ "r", "A", "rough", "equation", "presented", "in", "the", "HEDH", "for", "estimating", "the", "number", "of", "tubes", "in", "a", "tube", "bundle", "of", "differing", "geometries", "and", "tube", "sizes", ".", "No", "accuracy", "estimation", "given", ".", "...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L6135-L6184
44,318
CalebBell/ht
ht/hx.py
DBundle_for_Ntubes_HEDH
def DBundle_for_Ntubes_HEDH(N, Do, pitch, angle=30): r'''A rough equation presented in the HEDH for estimating the tube bundle diameter necessary to fit a given number of tubes. No accuracy estimation given. Only 1 pass is supported. .. math:: D_{bundle} = (D_o + (\text{pitch})\sqrt{\frac{1}{0...
python
def DBundle_for_Ntubes_HEDH(N, Do, pitch, angle=30): r'''A rough equation presented in the HEDH for estimating the tube bundle diameter necessary to fit a given number of tubes. No accuracy estimation given. Only 1 pass is supported. .. math:: D_{bundle} = (D_o + (\text{pitch})\sqrt{\frac{1}{0...
[ "def", "DBundle_for_Ntubes_HEDH", "(", "N", ",", "Do", ",", "pitch", ",", "angle", "=", "30", ")", ":", "if", "angle", "==", "30", "or", "angle", "==", "60", ":", "C1", "=", "13", "/", "15.", "elif", "angle", "==", "45", "or", "angle", "==", "90"...
r'''A rough equation presented in the HEDH for estimating the tube bundle diameter necessary to fit a given number of tubes. No accuracy estimation given. Only 1 pass is supported. .. math:: D_{bundle} = (D_o + (\text{pitch})\sqrt{\frac{1}{0.78}}\cdot \sqrt{C_1\cdot N}) C1 = 0.866 fo...
[ "r", "A", "rough", "equation", "presented", "in", "the", "HEDH", "for", "estimating", "the", "tube", "bundle", "diameter", "necessary", "to", "fit", "a", "given", "number", "of", "tubes", ".", "No", "accuracy", "estimation", "given", ".", "Only", "1", "pas...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L6187-L6236
44,319
timkpaine/perspective-python
perspective/base.py
PerspectiveBaseMixin.setup
def setup(self, data, view='hypergrid', schema=None, columns=None, rowpivots=None, columnpivots=None, aggregates=None, sort=None, index='', limit=-1, computedcolumns=...
python
def setup(self, data, view='hypergrid', schema=None, columns=None, rowpivots=None, columnpivots=None, aggregates=None, sort=None, index='', limit=-1, computedcolumns=...
[ "def", "setup", "(", "self", ",", "data", ",", "view", "=", "'hypergrid'", ",", "schema", "=", "None", ",", "columns", "=", "None", ",", "rowpivots", "=", "None", ",", "columnpivots", "=", "None", ",", "aggregates", "=", "None", ",", "sort", "=", "No...
Setup perspective base class Arguments: data : dataframe/list/dict The static or live datasource Keyword Arguments: view : str or View what view to use. available in the enum View (default: {'hypergrid'}) columns : list of str ...
[ "Setup", "perspective", "base", "class" ]
34cc59811909bc74d11e3de80010a3066ba9a8be
https://github.com/timkpaine/perspective-python/blob/34cc59811909bc74d11e3de80010a3066ba9a8be/perspective/base.py#L139-L202
44,320
CalebBell/ht
ht/conduction.py
R_cylinder
def R_cylinder(Di, Do, k, L): r'''Returns the thermal resistance `R` of a cylinder of constant thermal conductivity `k`, of inner and outer diameter `Di` and `Do`, and with a length `L`. .. math:: (hA)_{\text{cylinder}}=\frac{k}{\ln(D_o/D_i)} \cdot 2\pi L\\ R_{\text{cylinder}}=\frac{1}{...
python
def R_cylinder(Di, Do, k, L): r'''Returns the thermal resistance `R` of a cylinder of constant thermal conductivity `k`, of inner and outer diameter `Di` and `Do`, and with a length `L`. .. math:: (hA)_{\text{cylinder}}=\frac{k}{\ln(D_o/D_i)} \cdot 2\pi L\\ R_{\text{cylinder}}=\frac{1}{...
[ "def", "R_cylinder", "(", "Di", ",", "Do", ",", "k", ",", "L", ")", ":", "hA", "=", "k", "*", "2", "*", "pi", "*", "L", "/", "log", "(", "Do", "/", "Di", ")", "return", "1.", "/", "hA" ]
r'''Returns the thermal resistance `R` of a cylinder of constant thermal conductivity `k`, of inner and outer diameter `Di` and `Do`, and with a length `L`. .. math:: (hA)_{\text{cylinder}}=\frac{k}{\ln(D_o/D_i)} \cdot 2\pi L\\ R_{\text{cylinder}}=\frac{1}{(hA)_{\text{cylinder}}}= \...
[ "r", "Returns", "the", "thermal", "resistance", "R", "of", "a", "cylinder", "of", "constant", "thermal", "conductivity", "k", "of", "inner", "and", "outer", "diameter", "Di", "and", "Do", "and", "with", "a", "length", "L", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conduction.py#L272-L310
44,321
CalebBell/ht
ht/conduction.py
S_isothermal_pipe_to_isothermal_pipe
def S_isothermal_pipe_to_isothermal_pipe(D1, D2, W, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `w` distance from another infinite pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain a dimensionles...
python
def S_isothermal_pipe_to_isothermal_pipe(D1, D2, W, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `w` distance from another infinite pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain a dimensionles...
[ "def", "S_isothermal_pipe_to_isothermal_pipe", "(", "D1", ",", "D2", ",", "W", ",", "L", "=", "1.", ")", ":", "return", "2.", "*", "pi", "*", "L", "/", "acosh", "(", "(", "4", "*", "W", "**", "2", "-", "D1", "**", "2", "-", "D2", "**", "2", "...
r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `w` distance from another infinite pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain a dimensionless shape factor used in some sources. .. math:: S =...
[ "r", "Returns", "the", "Shape", "factor", "S", "of", "a", "pipe", "of", "constant", "outer", "temperature", "and", "of", "outer", "diameter", "D1", "which", "is", "w", "distance", "from", "another", "infinite", "pipe", "of", "outer", "diameter", "D2", ".",...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conduction.py#L445-L490
44,322
CalebBell/ht
ht/conduction.py
S_isothermal_pipe_to_two_planes
def S_isothermal_pipe_to_two_planes(D, Z, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D` which is `Z` distance from two infinite isothermal planes of equal temperatures, parallel to each other and enclosing the pipe. Length `L` must be provided,...
python
def S_isothermal_pipe_to_two_planes(D, Z, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D` which is `Z` distance from two infinite isothermal planes of equal temperatures, parallel to each other and enclosing the pipe. Length `L` must be provided,...
[ "def", "S_isothermal_pipe_to_two_planes", "(", "D", ",", "Z", ",", "L", "=", "1.", ")", ":", "return", "2.", "*", "pi", "*", "L", "/", "log", "(", "8.", "*", "Z", "/", "(", "pi", "*", "D", ")", ")" ]
r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D` which is `Z` distance from two infinite isothermal planes of equal temperatures, parallel to each other and enclosing the pipe. Length `L` must be provided, but can be set to 1 to obtain a dimensionless sh...
[ "r", "Returns", "the", "Shape", "factor", "S", "of", "a", "pipe", "of", "constant", "outer", "temperature", "and", "of", "outer", "diameter", "D", "which", "is", "Z", "distance", "from", "two", "infinite", "isothermal", "planes", "of", "equal", "temperatures...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conduction.py#L493-L538
44,323
CalebBell/ht
ht/conduction.py
S_isothermal_pipe_eccentric_to_isothermal_pipe
def S_isothermal_pipe_eccentric_to_isothermal_pipe(D1, D2, Z, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `Z` distance from the center of another pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain...
python
def S_isothermal_pipe_eccentric_to_isothermal_pipe(D1, D2, Z, L=1.): r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `Z` distance from the center of another pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain...
[ "def", "S_isothermal_pipe_eccentric_to_isothermal_pipe", "(", "D1", ",", "D2", ",", "Z", ",", "L", "=", "1.", ")", ":", "return", "2.", "*", "pi", "*", "L", "/", "acosh", "(", "(", "D2", "**", "2", "+", "D1", "**", "2", "-", "4.", "*", "Z", "**",...
r'''Returns the Shape factor `S` of a pipe of constant outer temperature and of outer diameter `D1` which is `Z` distance from the center of another pipe of outer diameter`D2`. Length `L` must be provided, but can be set to 1 to obtain a dimensionless shape factor used in some sources. .. math:: ...
[ "r", "Returns", "the", "Shape", "factor", "S", "of", "a", "pipe", "of", "constant", "outer", "temperature", "and", "of", "outer", "diameter", "D1", "which", "is", "Z", "distance", "from", "the", "center", "of", "another", "pipe", "of", "outer", "diameter",...
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conduction.py#L541-L587
44,324
CalebBell/ht
ht/core.py
LMTD
def LMTD(Thi, Tho, Tci, Tco, counterflow=True): r'''Returns the log-mean temperature difference of an ideal counterflow or co-current heat exchanger. .. math:: \Delta T_{LMTD}=\frac{\Delta T_1-\Delta T_2}{\ln(\Delta T_1/\Delta T_2)} \text{For countercurrent: } \\ \Delta T_1=T_...
python
def LMTD(Thi, Tho, Tci, Tco, counterflow=True): r'''Returns the log-mean temperature difference of an ideal counterflow or co-current heat exchanger. .. math:: \Delta T_{LMTD}=\frac{\Delta T_1-\Delta T_2}{\ln(\Delta T_1/\Delta T_2)} \text{For countercurrent: } \\ \Delta T_1=T_...
[ "def", "LMTD", "(", "Thi", ",", "Tho", ",", "Tci", ",", "Tco", ",", "counterflow", "=", "True", ")", ":", "if", "counterflow", ":", "dTF1", "=", "Thi", "-", "Tco", "dTF2", "=", "Tho", "-", "Tci", "else", ":", "dTF1", "=", "Thi", "-", "Tci", "dT...
r'''Returns the log-mean temperature difference of an ideal counterflow or co-current heat exchanger. .. math:: \Delta T_{LMTD}=\frac{\Delta T_1-\Delta T_2}{\ln(\Delta T_1/\Delta T_2)} \text{For countercurrent: } \\ \Delta T_1=T_{h,i}-T_{c,o}\\ \Delta T_2=T_{h,o}-T_{c,i} ...
[ "r", "Returns", "the", "log", "-", "mean", "temperature", "difference", "of", "an", "ideal", "counterflow", "or", "co", "-", "current", "heat", "exchanger", "." ]
3097ef9524c4cf0068ad453c17b10ec9ce551eee
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/core.py#L37-L95
44,325
mrcagney/kml2geojson
kml2geojson/cli.py
k2g
def k2g(kml_path, output_dir, separate_folders, style_type, style_filename): """ Given a path to a KML file, convert it to a a GeoJSON FeatureCollection file and save it to the given output directory. If ``--separate_folders``, then create several GeoJSON files, one for each folder in the KML file that ...
python
def k2g(kml_path, output_dir, separate_folders, style_type, style_filename): """ Given a path to a KML file, convert it to a a GeoJSON FeatureCollection file and save it to the given output directory. If ``--separate_folders``, then create several GeoJSON files, one for each folder in the KML file that ...
[ "def", "k2g", "(", "kml_path", ",", "output_dir", ",", "separate_folders", ",", "style_type", ",", "style_filename", ")", ":", "m", ".", "convert", "(", "kml_path", ",", "output_dir", ",", "separate_folders", ",", "style_type", ",", "style_filename", ")" ]
Given a path to a KML file, convert it to a a GeoJSON FeatureCollection file and save it to the given output directory. If ``--separate_folders``, then create several GeoJSON files, one for each folder in the KML file that contains geodata or that has a descendant node that contains geodata. Warning: this can ...
[ "Given", "a", "path", "to", "a", "KML", "file", "convert", "it", "to", "a", "a", "GeoJSON", "FeatureCollection", "file", "and", "save", "it", "to", "the", "given", "output", "directory", "." ]
6c4720f2b1327d636e15ce397dd808c9df8580a5
https://github.com/mrcagney/kml2geojson/blob/6c4720f2b1327d636e15ce397dd808c9df8580a5/kml2geojson/cli.py#L15-L25
44,326
mrcagney/kml2geojson
kml2geojson/main.py
disambiguate
def disambiguate(names, mark='1'): """ Given a list of strings ``names``, return a new list of names where repeated names have been disambiguated by repeatedly appending the given mark. EXAMPLE:: >>> disambiguate(['sing', 'song', 'sing', 'sing']) ['sing', 'song', 'sing1', 'sing11'] ""...
python
def disambiguate(names, mark='1'): """ Given a list of strings ``names``, return a new list of names where repeated names have been disambiguated by repeatedly appending the given mark. EXAMPLE:: >>> disambiguate(['sing', 'song', 'sing', 'sing']) ['sing', 'song', 'sing1', 'sing11'] ""...
[ "def", "disambiguate", "(", "names", ",", "mark", "=", "'1'", ")", ":", "names_seen", "=", "set", "(", ")", "new_names", "=", "[", "]", "for", "name", "in", "names", ":", "new_name", "=", "name", "while", "new_name", "in", "names_seen", ":", "new_name"...
Given a list of strings ``names``, return a new list of names where repeated names have been disambiguated by repeatedly appending the given mark. EXAMPLE:: >>> disambiguate(['sing', 'song', 'sing', 'sing']) ['sing', 'song', 'sing1', 'sing11']
[ "Given", "a", "list", "of", "strings", "names", "return", "a", "new", "list", "of", "names", "where", "repeated", "names", "have", "been", "disambiguated", "by", "repeatedly", "appending", "the", "given", "mark", "." ]
6c4720f2b1327d636e15ce397dd808c9df8580a5
https://github.com/mrcagney/kml2geojson/blob/6c4720f2b1327d636e15ce397dd808c9df8580a5/kml2geojson/main.py#L151-L170
44,327
mrcagney/kml2geojson
kml2geojson/main.py
build_rgb_and_opacity
def build_rgb_and_opacity(s): """ Given a KML color string, return an equivalent RGB hex color string and an opacity float rounded to 2 decimal places. EXAMPLE:: >>> build_rgb_and_opacity('ee001122') ('#221100', 0.93) """ # Set defaults color = '000000' opacity = 1 if...
python
def build_rgb_and_opacity(s): """ Given a KML color string, return an equivalent RGB hex color string and an opacity float rounded to 2 decimal places. EXAMPLE:: >>> build_rgb_and_opacity('ee001122') ('#221100', 0.93) """ # Set defaults color = '000000' opacity = 1 if...
[ "def", "build_rgb_and_opacity", "(", "s", ")", ":", "# Set defaults", "color", "=", "'000000'", "opacity", "=", "1", "if", "s", ".", "startswith", "(", "'#'", ")", ":", "s", "=", "s", "[", "1", ":", "]", "if", "len", "(", "s", ")", "==", "8", ":"...
Given a KML color string, return an equivalent RGB hex color string and an opacity float rounded to 2 decimal places. EXAMPLE:: >>> build_rgb_and_opacity('ee001122') ('#221100', 0.93)
[ "Given", "a", "KML", "color", "string", "return", "an", "equivalent", "RGB", "hex", "color", "string", "and", "an", "opacity", "float", "rounded", "to", "2", "decimal", "places", "." ]
6c4720f2b1327d636e15ce397dd808c9df8580a5
https://github.com/mrcagney/kml2geojson/blob/6c4720f2b1327d636e15ce397dd808c9df8580a5/kml2geojson/main.py#L191-L215
44,328
mrcagney/kml2geojson
kml2geojson/main.py
build_svg_style
def build_svg_style(node): """ Given a DOM node, grab its top-level Style nodes, convert every one into a SVG style dictionary, put them in a master dictionary of the form #style ID -> SVG style dictionary, and return the result. The possible keys and values of each SVG style dictionary, the ...
python
def build_svg_style(node): """ Given a DOM node, grab its top-level Style nodes, convert every one into a SVG style dictionary, put them in a master dictionary of the form #style ID -> SVG style dictionary, and return the result. The possible keys and values of each SVG style dictionary, the ...
[ "def", "build_svg_style", "(", "node", ")", ":", "d", "=", "{", "}", "for", "item", "in", "get", "(", "node", ",", "'Style'", ")", ":", "style_id", "=", "'#'", "+", "attr", "(", "item", ",", "'id'", ")", "# Create style properties", "props", "=", "{"...
Given a DOM node, grab its top-level Style nodes, convert every one into a SVG style dictionary, put them in a master dictionary of the form #style ID -> SVG style dictionary, and return the result. The possible keys and values of each SVG style dictionary, the style options, are - ``iconUrl``: ...
[ "Given", "a", "DOM", "node", "grab", "its", "top", "-", "level", "Style", "nodes", "convert", "every", "one", "into", "a", "SVG", "style", "dictionary", "put", "them", "in", "a", "master", "dictionary", "of", "the", "form" ]
6c4720f2b1327d636e15ce397dd808c9df8580a5
https://github.com/mrcagney/kml2geojson/blob/6c4720f2b1327d636e15ce397dd808c9df8580a5/kml2geojson/main.py#L217-L278
44,329
Element-34/py.saunter
saunter/po/webdriver/page.py
Page.wait_for_available
def wait_for_available(self, locator): """ Synchronization to deal with elements that are present, and are visible :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: if self.is_element_available(locator): br...
python
def wait_for_available(self, locator): """ Synchronization to deal with elements that are present, and are visible :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: if self.is_element_available(locator): br...
[ "def", "wait_for_available", "(", "self", ",", "locator", ")", ":", "for", "i", "in", "range", "(", "timeout_seconds", ")", ":", "try", ":", "if", "self", ".", "is_element_available", "(", "locator", ")", ":", "break", "except", ":", "pass", "time", ".",...
Synchronization to deal with elements that are present, and are visible :raises: ElementVisiblityTimeout
[ "Synchronization", "to", "deal", "with", "elements", "that", "are", "present", "and", "are", "visible" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/po/webdriver/page.py#L58-L73
44,330
Element-34/py.saunter
saunter/po/webdriver/page.py
Page.wait_for_visible
def wait_for_visible(self, locator): """ Synchronization to deal with elements that are present, but are disabled until some action triggers their visibility. :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: if self.d...
python
def wait_for_visible(self, locator): """ Synchronization to deal with elements that are present, but are disabled until some action triggers their visibility. :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: if self.d...
[ "def", "wait_for_visible", "(", "self", ",", "locator", ")", ":", "for", "i", "in", "range", "(", "timeout_seconds", ")", ":", "try", ":", "if", "self", ".", "driver", ".", "is_visible", "(", "locator", ")", ":", "break", "except", ":", "pass", "time",...
Synchronization to deal with elements that are present, but are disabled until some action triggers their visibility. :raises: ElementVisiblityTimeout
[ "Synchronization", "to", "deal", "with", "elements", "that", "are", "present", "but", "are", "disabled", "until", "some", "action", "triggers", "their", "visibility", "." ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/po/webdriver/page.py#L75-L91
44,331
Element-34/py.saunter
saunter/po/webdriver/page.py
Page.wait_for_text
def wait_for_text(self, locator, text): """ Synchronization on some text being displayed in a particular element. :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: e = self.driver.find_element_by_locator(locator) ...
python
def wait_for_text(self, locator, text): """ Synchronization on some text being displayed in a particular element. :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: e = self.driver.find_element_by_locator(locator) ...
[ "def", "wait_for_text", "(", "self", ",", "locator", ",", "text", ")", ":", "for", "i", "in", "range", "(", "timeout_seconds", ")", ":", "try", ":", "e", "=", "self", ".", "driver", ".", "find_element_by_locator", "(", "locator", ")", "if", "e", ".", ...
Synchronization on some text being displayed in a particular element. :raises: ElementVisiblityTimeout
[ "Synchronization", "on", "some", "text", "being", "displayed", "in", "a", "particular", "element", "." ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/po/webdriver/page.py#L109-L125
44,332
Element-34/py.saunter
saunter/po/webdriver/page.py
Page.wait_for_element_not_present
def wait_for_element_not_present(self, locator): """ Synchronization helper to wait until some element is removed from the page :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): if self.driver.is_element_present(locator): time.slee...
python
def wait_for_element_not_present(self, locator): """ Synchronization helper to wait until some element is removed from the page :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): if self.driver.is_element_present(locator): time.slee...
[ "def", "wait_for_element_not_present", "(", "self", ",", "locator", ")", ":", "for", "i", "in", "range", "(", "timeout_seconds", ")", ":", "if", "self", ".", "driver", ".", "is_element_present", "(", "locator", ")", ":", "time", ".", "sleep", "(", "1", "...
Synchronization helper to wait until some element is removed from the page :raises: ElementVisiblityTimeout
[ "Synchronization", "helper", "to", "wait", "until", "some", "element", "is", "removed", "from", "the", "page" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/po/webdriver/page.py#L159-L172
44,333
praekelt/django-object-tools
object_tools/validation.py
validate
def validate(tool_class, model_class): """ Does basic ObjectTool option validation. """ if not hasattr(tool_class, 'name'): raise ImproperlyConfigured("No 'name' attribute found for tool %s." % ( tool_class.__name__ )) if not hasattr(tool_class, 'label'): raise I...
python
def validate(tool_class, model_class): """ Does basic ObjectTool option validation. """ if not hasattr(tool_class, 'name'): raise ImproperlyConfigured("No 'name' attribute found for tool %s." % ( tool_class.__name__ )) if not hasattr(tool_class, 'label'): raise I...
[ "def", "validate", "(", "tool_class", ",", "model_class", ")", ":", "if", "not", "hasattr", "(", "tool_class", ",", "'name'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"No 'name' attribute found for tool %s.\"", "%", "(", "tool_class", ".", "__name__", ")"...
Does basic ObjectTool option validation.
[ "Does", "basic", "ObjectTool", "option", "validation", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/validation.py#L8-L25
44,334
praekelt/django-object-tools
object_tools/options.py
ObjectTool.construct_form
def construct_form(self, request): """ Constructs form from POST method using self.form_class. """ if not hasattr(self, 'form_class'): return None if request.method == 'POST': form = self.form_class(self.model, request.POST, request.FILES) else: ...
python
def construct_form(self, request): """ Constructs form from POST method using self.form_class. """ if not hasattr(self, 'form_class'): return None if request.method == 'POST': form = self.form_class(self.model, request.POST, request.FILES) else: ...
[ "def", "construct_form", "(", "self", ",", "request", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'form_class'", ")", ":", "return", "None", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "self", ".", "form_class", "(", "sel...
Constructs form from POST method using self.form_class.
[ "Constructs", "form", "from", "POST", "method", "using", "self", ".", "form_class", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L44-L55
44,335
praekelt/django-object-tools
object_tools/options.py
ObjectTool.has_permission
def has_permission(self, user): """ Returns True if the given request has permission to use the tool. Can be overriden by the user in subclasses. """ return user.has_perm( self.model._meta.app_label + '.' + self.get_permission() )
python
def has_permission(self, user): """ Returns True if the given request has permission to use the tool. Can be overriden by the user in subclasses. """ return user.has_perm( self.model._meta.app_label + '.' + self.get_permission() )
[ "def", "has_permission", "(", "self", ",", "user", ")", ":", "return", "user", ".", "has_perm", "(", "self", ".", "model", ".", "_meta", ".", "app_label", "+", "'.'", "+", "self", ".", "get_permission", "(", ")", ")" ]
Returns True if the given request has permission to use the tool. Can be overriden by the user in subclasses.
[ "Returns", "True", "if", "the", "given", "request", "has", "permission", "to", "use", "the", "tool", ".", "Can", "be", "overriden", "by", "the", "user", "in", "subclasses", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L60-L67
44,336
praekelt/django-object-tools
object_tools/options.py
ObjectTool.media
def media(self, form): """ Collects admin and form media. """ js = ['admin/js/core.js', 'admin/js/admin/RelatedObjectLookups.js', 'admin/js/jquery.min.js', 'admin/js/jquery.init.js'] media = forms.Media( js=['%s%s' % (settings.STATIC_URL, u) for u in js...
python
def media(self, form): """ Collects admin and form media. """ js = ['admin/js/core.js', 'admin/js/admin/RelatedObjectLookups.js', 'admin/js/jquery.min.js', 'admin/js/jquery.init.js'] media = forms.Media( js=['%s%s' % (settings.STATIC_URL, u) for u in js...
[ "def", "media", "(", "self", ",", "form", ")", ":", "js", "=", "[", "'admin/js/core.js'", ",", "'admin/js/admin/RelatedObjectLookups.js'", ",", "'admin/js/jquery.min.js'", ",", "'admin/js/jquery.init.js'", "]", "media", "=", "forms", ".", "Media", "(", "js", "=", ...
Collects admin and form media.
[ "Collects", "admin", "and", "form", "media", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L69-L84
44,337
praekelt/django-object-tools
object_tools/options.py
ObjectTool._urls
def _urls(self): """ URL patterns for tool linked to _view method. """ info = ( self.model._meta.app_label, self.model._meta.model_name, self.name, ) urlpatterns = [ url(r'^%s/$' % self.name, self._view, name='%s_%s_%s' % info) ...
python
def _urls(self): """ URL patterns for tool linked to _view method. """ info = ( self.model._meta.app_label, self.model._meta.model_name, self.name, ) urlpatterns = [ url(r'^%s/$' % self.name, self._view, name='%s_%s_%s' % info) ...
[ "def", "_urls", "(", "self", ")", ":", "info", "=", "(", "self", ".", "model", ".", "_meta", ".", "app_label", ",", "self", ".", "model", ".", "_meta", ".", "model_name", ",", "self", ".", "name", ",", ")", "urlpatterns", "=", "[", "url", "(", "r...
URL patterns for tool linked to _view method.
[ "URL", "patterns", "for", "tool", "linked", "to", "_view", "method", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L96-L107
44,338
praekelt/django-object-tools
object_tools/options.py
ObjectTool.construct_context
def construct_context(self, request): """ Builds context with various required variables. """ opts = self.model._meta app_label = opts.app_label object_name = opts.object_name.lower() form = self.construct_form(request) media = self.media(form) co...
python
def construct_context(self, request): """ Builds context with various required variables. """ opts = self.model._meta app_label = opts.app_label object_name = opts.object_name.lower() form = self.construct_form(request) media = self.media(form) co...
[ "def", "construct_context", "(", "self", ",", "request", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "app_label", "=", "opts", ".", "app_label", "object_name", "=", "opts", ".", "object_name", ".", "lower", "(", ")", "form", "=", "self", ...
Builds context with various required variables.
[ "Builds", "context", "with", "various", "required", "variables", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L110-L138
44,339
praekelt/django-object-tools
object_tools/options.py
ObjectTool._view
def _view(self, request, extra_context=None): """ View wrapper taking care of houskeeping for painless form rendering. """ if not self.has_permission(request.user): raise PermissionDenied return self.view(request, self.construct_context(request))
python
def _view(self, request, extra_context=None): """ View wrapper taking care of houskeeping for painless form rendering. """ if not self.has_permission(request.user): raise PermissionDenied return self.view(request, self.construct_context(request))
[ "def", "_view", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "if", "not", "self", ".", "has_permission", "(", "request", ".", "user", ")", ":", "raise", "PermissionDenied", "return", "self", ".", "view", "(", "request", ",", ...
View wrapper taking care of houskeeping for painless form rendering.
[ "View", "wrapper", "taking", "care", "of", "houskeeping", "for", "painless", "form", "rendering", "." ]
5923c1ec315edb96bb377762f28efc83ddf121d4
https://github.com/praekelt/django-object-tools/blob/5923c1ec315edb96bb377762f28efc83ddf121d4/object_tools/options.py#L141-L148
44,340
Element-34/py.saunter
saunter/providers/csv_provider.py
CSVProvider.randomRow
def randomRow(self): """ Gets a random row from the provider :returns: List """ l = [] for row in self.data: l.append(row) return random.choice(l)
python
def randomRow(self): """ Gets a random row from the provider :returns: List """ l = [] for row in self.data: l.append(row) return random.choice(l)
[ "def", "randomRow", "(", "self", ")", ":", "l", "=", "[", "]", "for", "row", "in", "self", ".", "data", ":", "l", ".", "append", "(", "row", ")", "return", "random", ".", "choice", "(", "l", ")" ]
Gets a random row from the provider :returns: List
[ "Gets", "a", "random", "row", "from", "the", "provider" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/providers/csv_provider.py#L37-L46
44,341
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_equal
def verify_equal(self, first, second, msg=""): """ Soft assert for equality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_equal(first, se...
python
def verify_equal(self, first, second, msg=""): """ Soft assert for equality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_equal(first, se...
[ "def", "verify_equal", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_equal", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", ...
Soft assert for equality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "equality" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L22-L37
44,342
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_not_equal
def verify_not_equal(self, first, second, msg=""): """ Soft assert for inequality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_not_equal...
python
def verify_not_equal(self, first, second, msg=""): """ Soft assert for inequality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_not_equal...
[ "def", "verify_not_equal", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_not_equal", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ...
Soft assert for inequality :params want: the value to compare against :params second: the value to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "inequality" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L49-L64
44,343
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_true
def verify_true(self, expr, msg=None): """ Soft assert for whether the condition is true :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference """ try: self.assert_true(expr, msg) except AssertionError, e: ...
python
def verify_true(self, expr, msg=None): """ Soft assert for whether the condition is true :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference """ try: self.assert_true(expr, msg) except AssertionError, e: ...
[ "def", "verify_true", "(", "self", ",", "expr", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_true", "(", "expr", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", "=", "\"%s:\\n%s\"", "%", "("...
Soft assert for whether the condition is true :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "condition", "is", "true" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L75-L89
44,344
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_false
def verify_false(self, expr, msg=None): """ Soft assert for whether the condition is false :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference """ try: self.assert_false(expr, msg) except AssertionError, e: ...
python
def verify_false(self, expr, msg=None): """ Soft assert for whether the condition is false :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference """ try: self.assert_false(expr, msg) except AssertionError, e: ...
[ "def", "verify_false", "(", "self", ",", "expr", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_false", "(", "expr", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", "=", "\"%s:\\n%s\"", "%", "...
Soft assert for whether the condition is false :params expr: the statement to evaluate :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "condition", "is", "false" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L100-L114
44,345
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is
def verify_is(self, first, second, msg=None): """ Soft assert for whether the parameters evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ t...
python
def verify_is(self, first, second, msg=None): """ Soft assert for whether the parameters evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ t...
[ "def", "verify_is", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_is", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", ...
Soft assert for whether the parameters evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "parameters", "evaluate", "to", "the", "same", "object" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L126-L141
44,346
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is_not
def verify_is_not(self, first, second, msg=None): """ Soft assert for whether the parameters do not evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference ""...
python
def verify_is_not(self, first, second, msg=None): """ Soft assert for whether the parameters do not evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference ""...
[ "def", "verify_is_not", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_is_not", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", ...
Soft assert for whether the parameters do not evaluate to the same object :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "parameters", "do", "not", "evaluate", "to", "the", "same", "object" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L153-L168
44,347
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is_none
def verify_is_none(self, expr, msg=None): """ Soft assert for whether the expr is None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_is...
python
def verify_is_none(self, expr, msg=None): """ Soft assert for whether the expr is None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ try: self.assert_is...
[ "def", "verify_is_none", "(", "self", ",", "expr", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_is_none", "(", "expr", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", "=", "\"%s:\\n%s\"", "%",...
Soft assert for whether the expr is None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "expr", "is", "None" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L179-L194
44,348
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is_not_none
def verify_is_not_none(self, expr, msg=None): """ Soft assert for whether the expr is not None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ try: self.a...
python
def verify_is_not_none(self, expr, msg=None): """ Soft assert for whether the expr is not None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference """ try: self.a...
[ "def", "verify_is_not_none", "(", "self", ",", "expr", ",", "msg", "=", "None", ")", ":", "try", ":", "self", ".", "assert_is_not_none", "(", "expr", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", "=", "\"%s:\\n%s\""...
Soft assert for whether the expr is not None :params want: the object to compare against :params second: the object to compare with :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "expr", "is", "not", "None" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L205-L220
44,349
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_in
def verify_in(self, first, second, msg=""): """ Soft assert for whether the first is in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference """ try: self.assert_in(fi...
python
def verify_in(self, first, second, msg=""): """ Soft assert for whether the first is in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference """ try: self.assert_in(fi...
[ "def", "verify_in", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_in", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", "m", ...
Soft assert for whether the first is in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "first", "is", "in", "second" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L232-L247
44,350
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_not_in
def verify_not_in(self, first, second, msg=""): """ Soft assert for whether the first is not in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference """ try: self.asse...
python
def verify_not_in(self, first, second, msg=""): """ Soft assert for whether the first is not in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference """ try: self.asse...
[ "def", "verify_not_in", "(", "self", ",", "first", ",", "second", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_not_in", "(", "first", ",", "second", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", ...
Soft assert for whether the first is not in second :params first: the value to check :params second: the container to check in :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "first", "is", "not", "in", "second" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L259-L274
44,351
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is_instance
def verify_is_instance(self, obj, cls, msg=""): """ Soft assert for whether the is an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference """ try: self.assert...
python
def verify_is_instance(self, obj, cls, msg=""): """ Soft assert for whether the is an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference """ try: self.assert...
[ "def", "verify_is_instance", "(", "self", ",", "obj", ",", "cls", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_is_instance", "(", "obj", ",", "cls", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg", ":", ...
Soft assert for whether the is an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "is", "an", "instance", "of", "cls" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L286-L301
44,352
Element-34/py.saunter
saunter/matchers.py
Matchers.verify_is_not_instance
def verify_is_not_instance(self, obj, cls, msg=""): """ Soft assert for whether the is not an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference """ try: sel...
python
def verify_is_not_instance(self, obj, cls, msg=""): """ Soft assert for whether the is not an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference """ try: sel...
[ "def", "verify_is_not_instance", "(", "self", ",", "obj", ",", "cls", ",", "msg", "=", "\"\"", ")", ":", "try", ":", "self", ".", "assert_is_not_instance", "(", "obj", ",", "cls", ",", "msg", ")", "except", "AssertionError", ",", "e", ":", "if", "msg",...
Soft assert for whether the is not an instance of cls :params obj: the object instance :params cls: the class to compare against :params msg: (Optional) msg explaining the difference
[ "Soft", "assert", "for", "whether", "the", "is", "not", "an", "instance", "of", "cls" ]
bdc8480b1453e082872c80d3382d42565b8ed9c0
https://github.com/Element-34/py.saunter/blob/bdc8480b1453e082872c80d3382d42565b8ed9c0/saunter/matchers.py#L313-L328
44,353
serkanyersen/underscore.py
src/underscore.py
underscore.obj
def obj(self): """ Returns passed object but if chain method is used returns the last processed result """ if self._wrapped is not self.Null: return self._wrapped else: return self.object
python
def obj(self): """ Returns passed object but if chain method is used returns the last processed result """ if self._wrapped is not self.Null: return self._wrapped else: return self.object
[ "def", "obj", "(", "self", ")", ":", "if", "self", ".", "_wrapped", "is", "not", "self", ".", "Null", ":", "return", "self", ".", "_wrapped", "else", ":", "return", "self", ".", "object" ]
Returns passed object but if chain method is used returns the last processed result
[ "Returns", "passed", "object", "but", "if", "chain", "method", "is", "used", "returns", "the", "last", "processed", "result" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L115-L123
44,354
serkanyersen/underscore.py
src/underscore.py
underscore._wrap
def _wrap(self, ret): """ Returns result but ig chain method is used returns the object itself so we can chain """ if self.chained: self._wrapped = ret return self else: return ret
python
def _wrap(self, ret): """ Returns result but ig chain method is used returns the object itself so we can chain """ if self.chained: self._wrapped = ret return self else: return ret
[ "def", "_wrap", "(", "self", ",", "ret", ")", ":", "if", "self", ".", "chained", ":", "self", ".", "_wrapped", "=", "ret", "return", "self", "else", ":", "return", "ret" ]
Returns result but ig chain method is used returns the object itself so we can chain
[ "Returns", "result", "but", "ig", "chain", "method", "is", "used", "returns", "the", "object", "itself", "so", "we", "can", "chain" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L132-L141
44,355
serkanyersen/underscore.py
src/underscore.py
underscore._toOriginal
def _toOriginal(self, val): """ Pitty attempt to convert itertools result into a real object """ if self._clean.isTuple(): return tuple(val) elif self._clean.isList(): return list(val) elif self._clean.isDict(): return dict(val) else: ...
python
def _toOriginal(self, val): """ Pitty attempt to convert itertools result into a real object """ if self._clean.isTuple(): return tuple(val) elif self._clean.isList(): return list(val) elif self._clean.isDict(): return dict(val) else: ...
[ "def", "_toOriginal", "(", "self", ",", "val", ")", ":", "if", "self", ".", "_clean", ".", "isTuple", "(", ")", ":", "return", "tuple", "(", "val", ")", "elif", "self", ".", "_clean", ".", "isList", "(", ")", ":", "return", "list", "(", "val", ")...
Pitty attempt to convert itertools result into a real object
[ "Pitty", "attempt", "to", "convert", "itertools", "result", "into", "a", "real", "object" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L151-L161
44,356
serkanyersen/underscore.py
src/underscore.py
underscore.map
def map(self, func): """ Return the results of applying the iterator to each element. """ ns = self.Namespace() ns.results = [] def by(value, index, list, *args): ns.results.append(func(value, index, list)) _(self.obj).each(by) return self._wrap(ns.r...
python
def map(self, func): """ Return the results of applying the iterator to each element. """ ns = self.Namespace() ns.results = [] def by(value, index, list, *args): ns.results.append(func(value, index, list)) _(self.obj).each(by) return self._wrap(ns.r...
[ "def", "map", "(", "self", ",", "func", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "results", "=", "[", "]", "def", "by", "(", "value", ",", "index", ",", "list", ",", "*", "args", ")", ":", "ns", ".", "results", ".",...
Return the results of applying the iterator to each element.
[ "Return", "the", "results", "of", "applying", "the", "iterator", "to", "each", "element", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L185-L195
44,357
serkanyersen/underscore.py
src/underscore.py
underscore.reduceRight
def reduceRight(self, func): """ The right-associative version of reduce, also known as `foldr`. """ #foldr = lambda f, i: lambda s: reduce(f, s, i) x = self.obj[:] x.reverse() return self._wrap(functools.reduce(func, x))
python
def reduceRight(self, func): """ The right-associative version of reduce, also known as `foldr`. """ #foldr = lambda f, i: lambda s: reduce(f, s, i) x = self.obj[:] x.reverse() return self._wrap(functools.reduce(func, x))
[ "def", "reduceRight", "(", "self", ",", "func", ")", ":", "#foldr = lambda f, i: lambda s: reduce(f, s, i)", "x", "=", "self", ".", "obj", "[", ":", "]", "x", ".", "reverse", "(", ")", "return", "self", ".", "_wrap", "(", "functools", ".", "reduce", "(", ...
The right-associative version of reduce, also known as `foldr`.
[ "The", "right", "-", "associative", "version", "of", "reduce", "also", "known", "as", "foldr", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L221-L227
44,358
serkanyersen/underscore.py
src/underscore.py
underscore.find
def find(self, func): """ Return the first value which passes a truth test. Aliased as `detect`. """ self.ftmp = None def test(value, index, list): if func(value, index, list) is True: self.ftmp = value return True self...
python
def find(self, func): """ Return the first value which passes a truth test. Aliased as `detect`. """ self.ftmp = None def test(value, index, list): if func(value, index, list) is True: self.ftmp = value return True self...
[ "def", "find", "(", "self", ",", "func", ")", ":", "self", ".", "ftmp", "=", "None", "def", "test", "(", "value", ",", "index", ",", "list", ")", ":", "if", "func", "(", "value", ",", "index", ",", "list", ")", "is", "True", ":", "self", ".", ...
Return the first value which passes a truth test. Aliased as `detect`.
[ "Return", "the", "first", "value", "which", "passes", "a", "truth", "test", ".", "Aliased", "as", "detect", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L230-L242
44,359
serkanyersen/underscore.py
src/underscore.py
underscore.filter
def filter(self, func): """ Return all the elements that pass a truth test. """ return self._wrap(list(filter(func, self.obj)))
python
def filter(self, func): """ Return all the elements that pass a truth test. """ return self._wrap(list(filter(func, self.obj)))
[ "def", "filter", "(", "self", ",", "func", ")", ":", "return", "self", ".", "_wrap", "(", "list", "(", "filter", "(", "func", ",", "self", ".", "obj", ")", ")", ")" ]
Return all the elements that pass a truth test.
[ "Return", "all", "the", "elements", "that", "pass", "a", "truth", "test", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L245-L248
44,360
serkanyersen/underscore.py
src/underscore.py
underscore.reject
def reject(self, func): """ Return all the elements for which a truth test fails. """ return self._wrap(list(filter(lambda val: not func(val), self.obj)))
python
def reject(self, func): """ Return all the elements for which a truth test fails. """ return self._wrap(list(filter(lambda val: not func(val), self.obj)))
[ "def", "reject", "(", "self", ",", "func", ")", ":", "return", "self", ".", "_wrap", "(", "list", "(", "filter", "(", "lambda", "val", ":", "not", "func", "(", "val", ")", ",", "self", ".", "obj", ")", ")", ")" ]
Return all the elements for which a truth test fails.
[ "Return", "all", "the", "elements", "for", "which", "a", "truth", "test", "fails", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L251-L254
44,361
serkanyersen/underscore.py
src/underscore.py
underscore.all
def all(self, func=None): """ Determine whether all of the elements match a truth test. """ if func is None: func = lambda x, *args: x self.altmp = True def testEach(value, index, *args): if func(value, index, *args) is False: self.altmp =...
python
def all(self, func=None): """ Determine whether all of the elements match a truth test. """ if func is None: func = lambda x, *args: x self.altmp = True def testEach(value, index, *args): if func(value, index, *args) is False: self.altmp =...
[ "def", "all", "(", "self", ",", "func", "=", "None", ")", ":", "if", "func", "is", "None", ":", "func", "=", "lambda", "x", ",", "*", "args", ":", "x", "self", ".", "altmp", "=", "True", "def", "testEach", "(", "value", ",", "index", ",", "*", ...
Determine whether all of the elements match a truth test.
[ "Determine", "whether", "all", "of", "the", "elements", "match", "a", "truth", "test", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L256-L268
44,362
serkanyersen/underscore.py
src/underscore.py
underscore.any
def any(self, func=None): """ Determine if at least one element in the object matches a truth test. """ if func is None: func = lambda x, *args: x self.antmp = False def testEach(value, index, *args): if func(value, index, *args) is True: ...
python
def any(self, func=None): """ Determine if at least one element in the object matches a truth test. """ if func is None: func = lambda x, *args: x self.antmp = False def testEach(value, index, *args): if func(value, index, *args) is True: ...
[ "def", "any", "(", "self", ",", "func", "=", "None", ")", ":", "if", "func", "is", "None", ":", "func", "=", "lambda", "x", ",", "*", "args", ":", "x", "self", ".", "antmp", "=", "False", "def", "testEach", "(", "value", ",", "index", ",", "*",...
Determine if at least one element in the object matches a truth test.
[ "Determine", "if", "at", "least", "one", "element", "in", "the", "object", "matches", "a", "truth", "test", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L271-L286
44,363
serkanyersen/underscore.py
src/underscore.py
underscore.include
def include(self, target): """ Determine if a given value is included in the array or object using `is`. """ if self._clean.isDict(): return self._wrap(target in self.obj.values()) else: return self._wrap(target in self.obj)
python
def include(self, target): """ Determine if a given value is included in the array or object using `is`. """ if self._clean.isDict(): return self._wrap(target in self.obj.values()) else: return self._wrap(target in self.obj)
[ "def", "include", "(", "self", ",", "target", ")", ":", "if", "self", ".", "_clean", ".", "isDict", "(", ")", ":", "return", "self", ".", "_wrap", "(", "target", "in", "self", ".", "obj", ".", "values", "(", ")", ")", "else", ":", "return", "self...
Determine if a given value is included in the array or object using `is`.
[ "Determine", "if", "a", "given", "value", "is", "included", "in", "the", "array", "or", "object", "using", "is", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L289-L297
44,364
serkanyersen/underscore.py
src/underscore.py
underscore.shuffle
def shuffle(self): """ Shuffle an array. """ if(self._clean.isDict()): return self._wrap(list()) cloned = self.obj[:] random.shuffle(cloned) return self._wrap(cloned)
python
def shuffle(self): """ Shuffle an array. """ if(self._clean.isDict()): return self._wrap(list()) cloned = self.obj[:] random.shuffle(cloned) return self._wrap(cloned)
[ "def", "shuffle", "(", "self", ")", ":", "if", "(", "self", ".", "_clean", ".", "isDict", "(", ")", ")", ":", "return", "self", ".", "_wrap", "(", "list", "(", ")", ")", "cloned", "=", "self", ".", "obj", "[", ":", "]", "random", ".", "shuffle"...
Shuffle an array.
[ "Shuffle", "an", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L365-L374
44,365
serkanyersen/underscore.py
src/underscore.py
underscore.sortBy
def sortBy(self, val=None): """ Sort the object's values by a criterion produced by an iterator. """ if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: ...
python
def sortBy(self, val=None): """ Sort the object's values by a criterion produced by an iterator. """ if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: ...
[ "def", "sortBy", "(", "self", ",", "val", "=", "None", ")", ":", "if", "val", "is", "not", "None", ":", "if", "_", "(", "val", ")", ".", "isString", "(", ")", ":", "return", "self", ".", "_wrap", "(", "sorted", "(", "self", ".", "obj", ",", "...
Sort the object's values by a criterion produced by an iterator.
[ "Sort", "the", "object", "s", "values", "by", "a", "criterion", "produced", "by", "an", "iterator", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L376-L386
44,366
serkanyersen/underscore.py
src/underscore.py
underscore._lookupIterator
def _lookupIterator(self, val): """ An internal function to generate lookup iterators. """ if val is None: return lambda el, *args: el return val if _.isCallable(val) else lambda obj, *args: obj[val]
python
def _lookupIterator(self, val): """ An internal function to generate lookup iterators. """ if val is None: return lambda el, *args: el return val if _.isCallable(val) else lambda obj, *args: obj[val]
[ "def", "_lookupIterator", "(", "self", ",", "val", ")", ":", "if", "val", "is", "None", ":", "return", "lambda", "el", ",", "*", "args", ":", "el", "return", "val", "if", "_", ".", "isCallable", "(", "val", ")", "else", "lambda", "obj", ",", "*", ...
An internal function to generate lookup iterators.
[ "An", "internal", "function", "to", "generate", "lookup", "iterators", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L388-L393
44,367
serkanyersen/underscore.py
src/underscore.py
underscore._group
def _group(self, obj, val, behavior): """ An internal function used for aggregate "group by" operations. """ ns = self.Namespace() ns.result = {} iterator = self._lookupIterator(val) def e(value, index, *args): key = iterator(value, index) behavio...
python
def _group(self, obj, val, behavior): """ An internal function used for aggregate "group by" operations. """ ns = self.Namespace() ns.result = {} iterator = self._lookupIterator(val) def e(value, index, *args): key = iterator(value, index) behavio...
[ "def", "_group", "(", "self", ",", "obj", ",", "val", ",", "behavior", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "result", "=", "{", "}", "iterator", "=", "self", ".", "_lookupIterator", "(", "val", ")", "def", "e", "(",...
An internal function used for aggregate "group by" operations.
[ "An", "internal", "function", "used", "for", "aggregate", "group", "by", "operations", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L395-L413
44,368
serkanyersen/underscore.py
src/underscore.py
underscore.groupBy
def groupBy(self, val): """ Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key] = [] result[key]...
python
def groupBy(self, val): """ Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key] = [] result[key]...
[ "def", "groupBy", "(", "self", ",", "val", ")", ":", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "result", ":", "result", "[", "key", "]", "=", "[", "]", "result", "[", "key", "]", ".", "append", ...
Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion.
[ "Groups", "the", "object", "s", "values", "by", "a", "criterion", ".", "Pass", "either", "a", "string", "attribute", "to", "group", "by", "or", "a", "function", "that", "returns", "the", "criterion", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L415-L428
44,369
serkanyersen/underscore.py
src/underscore.py
underscore.indexBy
def indexBy(self, val=None): """ Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique. """ if val is None: val = lambda *args: args[0] def by(result, key, value): result[key]...
python
def indexBy(self, val=None): """ Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique. """ if val is None: val = lambda *args: args[0] def by(result, key, value): result[key]...
[ "def", "indexBy", "(", "self", ",", "val", "=", "None", ")", ":", "if", "val", "is", "None", ":", "val", "=", "lambda", "*", "args", ":", "args", "[", "0", "]", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "result", "[", "k...
Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique.
[ "Indexes", "the", "object", "s", "values", "by", "a", "criterion", "similar", "to", "groupBy", "but", "for", "when", "you", "know", "that", "your", "index", "values", "will", "be", "unique", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L430-L443
44,370
serkanyersen/underscore.py
src/underscore.py
underscore.countBy
def countBy(self, val): """ Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key...
python
def countBy(self, val): """ Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key...
[ "def", "countBy", "(", "self", ",", "val", ")", ":", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "result", ":", "result", "[", "key", "]", "=", "0", "result", "[", "key", "]", "+=", "1", "res", "=...
Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion.
[ "Counts", "instances", "of", "an", "object", "that", "group", "by", "a", "certain", "criterion", ".", "Pass", "either", "a", "string", "attribute", "to", "count", "by", "or", "a", "function", "that", "returns", "the", "criterion", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L445-L459
44,371
serkanyersen/underscore.py
src/underscore.py
underscore.sortedIndex
def sortedIndex(self, obj, iterator=lambda x: x): """ Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search. """ array = self.obj value = iterator(obj) low = 0 h...
python
def sortedIndex(self, obj, iterator=lambda x: x): """ Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search. """ array = self.obj value = iterator(obj) low = 0 h...
[ "def", "sortedIndex", "(", "self", ",", "obj", ",", "iterator", "=", "lambda", "x", ":", "x", ")", ":", "array", "=", "self", ".", "obj", "value", "=", "iterator", "(", "obj", ")", "low", "=", "0", "high", "=", "len", "(", "array", ")", "while", ...
Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search.
[ "Use", "a", "comparator", "function", "to", "figure", "out", "the", "smallest", "index", "at", "which", "an", "object", "should", "be", "inserted", "so", "as", "to", "maintain", "order", ".", "Uses", "binary", "search", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L461-L477
44,372
serkanyersen/underscore.py
src/underscore.py
underscore.flatten
def flatten(self, shallow=None): """ Return a completely flattened version of an array. """ return self._wrap(self._flatten(self.obj, shallow))
python
def flatten(self, shallow=None): """ Return a completely flattened version of an array. """ return self._wrap(self._flatten(self.obj, shallow))
[ "def", "flatten", "(", "self", ",", "shallow", "=", "None", ")", ":", "return", "self", ".", "_wrap", "(", "self", ".", "_flatten", "(", "self", ".", "obj", ",", "shallow", ")", ")" ]
Return a completely flattened version of an array.
[ "Return", "a", "completely", "flattened", "version", "of", "an", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L556-L559
44,373
serkanyersen/underscore.py
src/underscore.py
underscore.uniq
def uniq(self, isSorted=False, iterator=None): """ Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`. """ ns = self.Namespace() ns.results = [] ns.array...
python
def uniq(self, isSorted=False, iterator=None): """ Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`. """ ns = self.Namespace() ns.results = [] ns.array...
[ "def", "uniq", "(", "self", ",", "isSorted", "=", "False", ",", "iterator", "=", "None", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "results", "=", "[", "]", "ns", ".", "array", "=", "self", ".", "obj", "initial", "=", ...
Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`.
[ "Produce", "a", "duplicate", "-", "free", "version", "of", "the", "array", ".", "If", "the", "array", "has", "already", "been", "sorted", "you", "have", "the", "option", "of", "using", "a", "faster", "algorithm", ".", "Aliased", "as", "unique", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L597-L619
44,374
serkanyersen/underscore.py
src/underscore.py
underscore.intersection
def intersection(self, *args): """ Produce an array that contains every item shared between all the passed-in arrays. """ if type(self.obj[0]) is int: a = self.obj else: a = tuple(self.obj[0]) setobj = set(a) for i, v in enumerate(a...
python
def intersection(self, *args): """ Produce an array that contains every item shared between all the passed-in arrays. """ if type(self.obj[0]) is int: a = self.obj else: a = tuple(self.obj[0]) setobj = set(a) for i, v in enumerate(a...
[ "def", "intersection", "(", "self", ",", "*", "args", ")", ":", "if", "type", "(", "self", ".", "obj", "[", "0", "]", ")", "is", "int", ":", "a", "=", "self", ".", "obj", "else", ":", "a", "=", "tuple", "(", "self", ".", "obj", "[", "0", "]...
Produce an array that contains every item shared between all the passed-in arrays.
[ "Produce", "an", "array", "that", "contains", "every", "item", "shared", "between", "all", "the", "passed", "-", "in", "arrays", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L639-L651
44,375
serkanyersen/underscore.py
src/underscore.py
underscore.difference
def difference(self, *args): """ Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain. """ setobj = set(self.obj) for i, v in enumerate(args): setobj = setobj - set(args[i]) r...
python
def difference(self, *args): """ Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain. """ setobj = set(self.obj) for i, v in enumerate(args): setobj = setobj - set(args[i]) r...
[ "def", "difference", "(", "self", ",", "*", "args", ")", ":", "setobj", "=", "set", "(", "self", ".", "obj", ")", "for", "i", ",", "v", "in", "enumerate", "(", "args", ")", ":", "setobj", "=", "setobj", "-", "set", "(", "args", "[", "i", "]", ...
Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain.
[ "Take", "the", "difference", "between", "one", "array", "and", "a", "number", "of", "other", "arrays", ".", "Only", "the", "elements", "present", "in", "just", "the", "first", "array", "will", "remain", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L653-L661
44,376
serkanyersen/underscore.py
src/underscore.py
underscore.indexOf
def indexOf(self, item, isSorted=False): """ Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj ret = -1 if not (self._clean.isList() or self._clean.isTuple()): retu...
python
def indexOf(self, item, isSorted=False): """ Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj ret = -1 if not (self._clean.isList() or self._clean.isTuple()): retu...
[ "def", "indexOf", "(", "self", ",", "item", ",", "isSorted", "=", "False", ")", ":", "array", "=", "self", ".", "obj", "ret", "=", "-", "1", "if", "not", "(", "self", ".", "_clean", ".", "isList", "(", ")", "or", "self", ".", "_clean", ".", "is...
Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array.
[ "Return", "the", "position", "of", "the", "first", "occurrence", "of", "an", "item", "in", "an", "array", "or", "-", "1", "if", "the", "item", "is", "not", "included", "in", "the", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L695-L716
44,377
serkanyersen/underscore.py
src/underscore.py
underscore.lastIndexOf
def lastIndexOf(self, item): """ Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj i = len(array) - 1 if not (self._clean.isList() or self._clean.isTuple()): return s...
python
def lastIndexOf(self, item): """ Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj i = len(array) - 1 if not (self._clean.isList() or self._clean.isTuple()): return s...
[ "def", "lastIndexOf", "(", "self", ",", "item", ")", ":", "array", "=", "self", ".", "obj", "i", "=", "len", "(", "array", ")", "-", "1", "if", "not", "(", "self", ".", "_clean", ".", "isList", "(", ")", "or", "self", ".", "_clean", ".", "isTup...
Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array.
[ "Return", "the", "position", "of", "the", "last", "occurrence", "of", "an", "item", "in", "an", "array", "or", "-", "1", "if", "the", "item", "is", "not", "included", "in", "the", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L718-L732
44,378
serkanyersen/underscore.py
src/underscore.py
underscore.range
def range(self, *args): """ Generate an integer Array containing an arithmetic progression. """ args = list(args) args.insert(0, self.obj) return self._wrap(range(*args))
python
def range(self, *args): """ Generate an integer Array containing an arithmetic progression. """ args = list(args) args.insert(0, self.obj) return self._wrap(range(*args))
[ "def", "range", "(", "self", ",", "*", "args", ")", ":", "args", "=", "list", "(", "args", ")", "args", ".", "insert", "(", "0", ",", "self", ".", "obj", ")", "return", "self", ".", "_wrap", "(", "range", "(", "*", "args", ")", ")" ]
Generate an integer Array containing an arithmetic progression.
[ "Generate", "an", "integer", "Array", "containing", "an", "arithmetic", "progression", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L734-L739
44,379
serkanyersen/underscore.py
src/underscore.py
underscore.partial
def partial(self, *args): """ Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context. """ def part(*args2): args3 = args + args2 return self.obj(*args3) return se...
python
def partial(self, *args): """ Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context. """ def part(*args2): args3 = args + args2 return self.obj(*args3) return se...
[ "def", "partial", "(", "self", ",", "*", "args", ")", ":", "def", "part", "(", "*", "args2", ")", ":", "args3", "=", "args", "+", "args2", "return", "self", ".", "obj", "(", "*", "args3", ")", "return", "self", ".", "_wrap", "(", "part", ")" ]
Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context.
[ "Partially", "apply", "a", "function", "by", "creating", "a", "version", "that", "has", "had", "some", "of", "its", "arguments", "pre", "-", "filled", "without", "changing", "its", "dynamic", "this", "context", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L754-L763
44,380
serkanyersen/underscore.py
src/underscore.py
underscore.memoize
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
python
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
[ "def", "memoize", "(", "self", ",", "hasher", "=", "None", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "memo", "=", "{", "}", "if", "hasher", "is", "None", ":", "hasher", "=", "lambda", "x", ":", "x", "def", "memoized", ...
Memoize an expensive function by storing its results.
[ "Memoize", "an", "expensive", "function", "by", "storing", "its", "results", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L773-L787
44,381
serkanyersen/underscore.py
src/underscore.py
underscore.delay
def delay(self, wait, *args): """ Delays a function for the given number of milliseconds, and then calls it with the arguments supplied. """ def call_it(): self.obj(*args) t = Timer((float(wait) / float(1000)), call_it) t.start() return self....
python
def delay(self, wait, *args): """ Delays a function for the given number of milliseconds, and then calls it with the arguments supplied. """ def call_it(): self.obj(*args) t = Timer((float(wait) / float(1000)), call_it) t.start() return self....
[ "def", "delay", "(", "self", ",", "wait", ",", "*", "args", ")", ":", "def", "call_it", "(", ")", ":", "self", ".", "obj", "(", "*", "args", ")", "t", "=", "Timer", "(", "(", "float", "(", "wait", ")", "/", "float", "(", "1000", ")", ")", "...
Delays a function for the given number of milliseconds, and then calls it with the arguments supplied.
[ "Delays", "a", "function", "for", "the", "given", "number", "of", "milliseconds", "and", "then", "calls", "it", "with", "the", "arguments", "supplied", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L789-L800
44,382
serkanyersen/underscore.py
src/underscore.py
underscore.throttle
def throttle(self, wait): """ Returns a function, that, when invoked, will only be triggered at most once during a given window of time. """ ns = self.Namespace() ns.timeout = None ns.throttling = None ns.more = None ns.result = None def d...
python
def throttle(self, wait): """ Returns a function, that, when invoked, will only be triggered at most once during a given window of time. """ ns = self.Namespace() ns.timeout = None ns.throttling = None ns.more = None ns.result = None def d...
[ "def", "throttle", "(", "self", ",", "wait", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "timeout", "=", "None", "ns", ".", "throttling", "=", "None", "ns", ".", "more", "=", "None", "ns", ".", "result", "=", "None", "def"...
Returns a function, that, when invoked, will only be triggered at most once during a given window of time.
[ "Returns", "a", "function", "that", "when", "invoked", "will", "only", "be", "triggered", "at", "most", "once", "during", "a", "given", "window", "of", "time", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L810-L845
44,383
serkanyersen/underscore.py
src/underscore.py
underscore.debounce
def debounce(self, wait, immediate=None): """ Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, in...
python
def debounce(self, wait, immediate=None): """ Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, in...
[ "def", "debounce", "(", "self", ",", "wait", ",", "immediate", "=", "None", ")", ":", "wait", "=", "(", "float", "(", "wait", ")", "/", "float", "(", "1000", ")", ")", "def", "debounced", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "de...
Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, instead of the trailing.
[ "Returns", "a", "function", "that", "as", "long", "as", "it", "continues", "to", "be", "invoked", "will", "not", "be", "triggered", ".", "The", "function", "will", "be", "called", "after", "it", "stops", "being", "called", "for", "N", "milliseconds", ".", ...
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L848-L866
44,384
serkanyersen/underscore.py
src/underscore.py
underscore.once
def once(self): """ Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization. """ ns = self.Namespace() ns.memo = None ns.run = False def work_once(*args, **kwargs): if ns.run i...
python
def once(self): """ Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization. """ ns = self.Namespace() ns.memo = None ns.run = False def work_once(*args, **kwargs): if ns.run i...
[ "def", "once", "(", "self", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "memo", "=", "None", "ns", ".", "run", "=", "False", "def", "work_once", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "ns", ".", "ru...
Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization.
[ "Returns", "a", "function", "that", "will", "be", "executed", "at", "most", "one", "time", "no", "matter", "how", "often", "you", "call", "it", ".", "Useful", "for", "lazy", "initialization", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L868-L883
44,385
serkanyersen/underscore.py
src/underscore.py
underscore.wrap
def wrap(self, wrapper): """ Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function. """ def wrapped(*args, **kwargs): if kwargs: ...
python
def wrap(self, wrapper): """ Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function. """ def wrapped(*args, **kwargs): if kwargs: ...
[ "def", "wrap", "(", "self", ",", "wrapper", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "kwargs", "[", "\"object\"", "]", "=", "self", ".", "obj", "else", ":", "args", "=", "list", "(", ...
Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function.
[ "Returns", "the", "first", "function", "passed", "as", "an", "argument", "to", "the", "second", "allowing", "you", "to", "adjust", "arguments", "run", "code", "before", "and", "after", "and", "conditionally", "execute", "the", "original", "function", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L885-L901
44,386
serkanyersen/underscore.py
src/underscore.py
underscore.compose
def compose(self, *args): """ Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows. """ args = list(args) def composed(*ar, **kwargs): lastRet = self.obj(*ar, **kwargs) for...
python
def compose(self, *args): """ Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows. """ args = list(args) def composed(*ar, **kwargs): lastRet = self.obj(*ar, **kwargs) for...
[ "def", "compose", "(", "self", ",", "*", "args", ")", ":", "args", "=", "list", "(", "args", ")", "def", "composed", "(", "*", "ar", ",", "*", "*", "kwargs", ")", ":", "lastRet", "=", "self", ".", "obj", "(", "*", "ar", ",", "*", "*", "kwargs...
Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows.
[ "Returns", "a", "function", "that", "is", "the", "composition", "of", "a", "list", "of", "functions", "each", "consuming", "the", "return", "value", "of", "the", "function", "that", "follows", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L903-L917
44,387
serkanyersen/underscore.py
src/underscore.py
underscore.after
def after(self, func): """ Returns a function that will only be executed after being called N times. """ ns = self.Namespace() ns.times = self.obj if ns.times <= 0: return func() def work_after(*args): if ns.times <= 1: ...
python
def after(self, func): """ Returns a function that will only be executed after being called N times. """ ns = self.Namespace() ns.times = self.obj if ns.times <= 0: return func() def work_after(*args): if ns.times <= 1: ...
[ "def", "after", "(", "self", ",", "func", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "times", "=", "self", ".", "obj", "if", "ns", ".", "times", "<=", "0", ":", "return", "func", "(", ")", "def", "work_after", "(", "*",...
Returns a function that will only be executed after being called N times.
[ "Returns", "a", "function", "that", "will", "only", "be", "executed", "after", "being", "called", "N", "times", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L919-L935
44,388
serkanyersen/underscore.py
src/underscore.py
underscore.invert
def invert(self): """ Invert the keys and values of an object. The values must be serializable. """ keys = self._clean.keys() inverted = {} for key in keys: inverted[self.obj[key]] = key return self._wrap(inverted)
python
def invert(self): """ Invert the keys and values of an object. The values must be serializable. """ keys = self._clean.keys() inverted = {} for key in keys: inverted[self.obj[key]] = key return self._wrap(inverted)
[ "def", "invert", "(", "self", ")", ":", "keys", "=", "self", ".", "_clean", ".", "keys", "(", ")", "inverted", "=", "{", "}", "for", "key", "in", "keys", ":", "inverted", "[", "self", ".", "obj", "[", "key", "]", "]", "=", "key", "return", "sel...
Invert the keys and values of an object. The values must be serializable.
[ "Invert", "the", "keys", "and", "values", "of", "an", "object", ".", "The", "values", "must", "be", "serializable", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L961-L971
44,389
serkanyersen/underscore.py
src/underscore.py
underscore.functions
def functions(self): """ Return a sorted list of the function names available on the object. """ names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
python
def functions(self): """ Return a sorted list of the function names available on the object. """ names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
[ "def", "functions", "(", "self", ")", ":", "names", "=", "[", "]", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "obj", ")", ":", "if", "_", "(", "self", ".", "obj", "[", "k", "]", ")", ".", "isCallable", "(", ")", ":", "names", ...
Return a sorted list of the function names available on the object.
[ "Return", "a", "sorted", "list", "of", "the", "function", "names", "available", "on", "the", "object", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L973-L982
44,390
serkanyersen/underscore.py
src/underscore.py
underscore.pick
def pick(self, *args): """ Return a copy of the object only containing the whitelisted properties. """ ns = self.Namespace() ns.result = {} def by(key, *args): if key in self.obj: ns.result[key] = self.obj[key] _.each(self._fl...
python
def pick(self, *args): """ Return a copy of the object only containing the whitelisted properties. """ ns = self.Namespace() ns.result = {} def by(key, *args): if key in self.obj: ns.result[key] = self.obj[key] _.each(self._fl...
[ "def", "pick", "(", "self", ",", "*", "args", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "result", "=", "{", "}", "def", "by", "(", "key", ",", "*", "args", ")", ":", "if", "key", "in", "self", ".", "obj", ":", "ns"...
Return a copy of the object only containing the whitelisted properties.
[ "Return", "a", "copy", "of", "the", "object", "only", "containing", "the", "whitelisted", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L996-L1009
44,391
serkanyersen/underscore.py
src/underscore.py
underscore.defaults
def defaults(self, *args): """ Fill in a given object with default properties. """ ns = self.Namespace ns.obj = self.obj def by(source, *ar): for i, prop in enumerate(source): if prop not in ns.obj: ns.obj[prop] = source[prop] ...
python
def defaults(self, *args): """ Fill in a given object with default properties. """ ns = self.Namespace ns.obj = self.obj def by(source, *ar): for i, prop in enumerate(source): if prop not in ns.obj: ns.obj[prop] = source[prop] ...
[ "def", "defaults", "(", "self", ",", "*", "args", ")", ":", "ns", "=", "self", ".", "Namespace", "ns", ".", "obj", "=", "self", ".", "obj", "def", "by", "(", "source", ",", "*", "ar", ")", ":", "for", "i", ",", "prop", "in", "enumerate", "(", ...
Fill in a given object with default properties.
[ "Fill", "in", "a", "given", "object", "with", "default", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1020-L1033
44,392
serkanyersen/underscore.py
src/underscore.py
underscore.tap
def tap(self, interceptor): """ Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. """ interceptor(self.obj) return se...
python
def tap(self, interceptor): """ Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. """ interceptor(self.obj) return se...
[ "def", "tap", "(", "self", ",", "interceptor", ")", ":", "interceptor", "(", "self", ".", "obj", ")", "return", "self", ".", "_wrap", "(", "self", ".", "obj", ")" ]
Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
[ "Invokes", "interceptor", "with", "the", "obj", "and", "then", "returns", "obj", ".", "The", "primary", "purpose", "of", "this", "method", "is", "to", "tap", "into", "a", "method", "chain", "in", "order", "to", "perform", "operations", "on", "intermediate", ...
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1041-L1048
44,393
serkanyersen/underscore.py
src/underscore.py
underscore.isEmpty
def isEmpty(self): """ Is a given array, string, or object empty? An "empty" object has no enumerable own-properties. """ if self.obj is None: return True if self._clean.isString(): ret = self.obj.strip() is "" elif self._clean.isDict(): ...
python
def isEmpty(self): """ Is a given array, string, or object empty? An "empty" object has no enumerable own-properties. """ if self.obj is None: return True if self._clean.isString(): ret = self.obj.strip() is "" elif self._clean.isDict(): ...
[ "def", "isEmpty", "(", "self", ")", ":", "if", "self", ".", "obj", "is", "None", ":", "return", "True", "if", "self", ".", "_clean", ".", "isString", "(", ")", ":", "ret", "=", "self", ".", "obj", ".", "strip", "(", ")", "is", "\"\"", "elif", "...
Is a given array, string, or object empty? An "empty" object has no enumerable own-properties.
[ "Is", "a", "given", "array", "string", "or", "object", "empty?", "An", "empty", "object", "has", "no", "enumerable", "own", "-", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1055-L1068
44,394
serkanyersen/underscore.py
src/underscore.py
underscore.isFile
def isFile(self): """ Check if the given object is a file """ try: filetype = file except NameError: filetype = io.IOBase return self._wrap(type(self.obj) is filetype)
python
def isFile(self): """ Check if the given object is a file """ try: filetype = file except NameError: filetype = io.IOBase return self._wrap(type(self.obj) is filetype)
[ "def", "isFile", "(", "self", ")", ":", "try", ":", "filetype", "=", "file", "except", "NameError", ":", "filetype", "=", "io", ".", "IOBase", "return", "self", ".", "_wrap", "(", "type", "(", "self", ".", "obj", ")", "is", "filetype", ")" ]
Check if the given object is a file
[ "Check", "if", "the", "given", "object", "is", "a", "file" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1202-L1210
44,395
serkanyersen/underscore.py
src/underscore.py
underscore.join
def join(self, glue=" "): """ Javascript's join implementation """ j = glue.join([str(x) for x in self.obj]) return self._wrap(j)
python
def join(self, glue=" "): """ Javascript's join implementation """ j = glue.join([str(x) for x in self.obj]) return self._wrap(j)
[ "def", "join", "(", "self", ",", "glue", "=", "\" \"", ")", ":", "j", "=", "glue", ".", "join", "(", "[", "str", "(", "x", ")", "for", "x", "in", "self", ".", "obj", "]", ")", "return", "self", ".", "_wrap", "(", "j", ")" ]
Javascript's join implementation
[ "Javascript", "s", "join", "implementation" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1275-L1279
44,396
serkanyersen/underscore.py
src/underscore.py
underscore.result
def result(self, property, *args): """ If the value of the named property is a function then invoke it; otherwise, return it. """ if self.obj is None: return self._wrap(self.obj) if(hasattr(self.obj, property)): value = getattr(self.obj, property)...
python
def result(self, property, *args): """ If the value of the named property is a function then invoke it; otherwise, return it. """ if self.obj is None: return self._wrap(self.obj) if(hasattr(self.obj, property)): value = getattr(self.obj, property)...
[ "def", "result", "(", "self", ",", "property", ",", "*", "args", ")", ":", "if", "self", ".", "obj", "is", "None", ":", "return", "self", ".", "_wrap", "(", "self", ".", "obj", ")", "if", "(", "hasattr", "(", "self", ".", "obj", ",", "property", ...
If the value of the named property is a function then invoke it; otherwise, return it.
[ "If", "the", "value", "of", "the", "named", "property", "is", "a", "function", "then", "invoke", "it", ";", "otherwise", "return", "it", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1339-L1353
44,397
serkanyersen/underscore.py
src/underscore.py
underscore.mixin
def mixin(self): """ Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well. """ methods = self.obj for i, k in enumerate(methods): setattr(underscore, k, methods[k]) self.makeStatic() ...
python
def mixin(self): """ Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well. """ methods = self.obj for i, k in enumerate(methods): setattr(underscore, k, methods[k]) self.makeStatic() ...
[ "def", "mixin", "(", "self", ")", ":", "methods", "=", "self", ".", "obj", "for", "i", ",", "k", "in", "enumerate", "(", "methods", ")", ":", "setattr", "(", "underscore", ",", "k", ",", "methods", "[", "k", "]", ")", "self", ".", "makeStatic", "...
Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well.
[ "Add", "your", "own", "custom", "functions", "to", "the", "Underscore", "object", "ensuring", "that", "they", "re", "correctly", "added", "to", "the", "OOP", "wrapper", "as", "well", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1355-L1365
44,398
serkanyersen/underscore.py
src/underscore.py
underscore.escape
def escape(self): """ Escape a string for HTML interpolation. """ # & must be handled first self.obj = self.obj.replace("&", self._html_escape_table["&"]) for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] if k is not "&": ...
python
def escape(self): """ Escape a string for HTML interpolation. """ # & must be handled first self.obj = self.obj.replace("&", self._html_escape_table["&"]) for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] if k is not "&": ...
[ "def", "escape", "(", "self", ")", ":", "# & must be handled first", "self", ".", "obj", "=", "self", ".", "obj", ".", "replace", "(", "\"&\"", ",", "self", ".", "_html_escape_table", "[", "\"&\"", "]", ")", "for", "i", ",", "k", "in", "enumerate", "("...
Escape a string for HTML interpolation.
[ "Escape", "a", "string", "for", "HTML", "interpolation", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1387-L1398
44,399
serkanyersen/underscore.py
src/underscore.py
underscore.unescape
def unescape(self): """ Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added. """ for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] self.obj = self.obj.replace(v, k) ret...
python
def unescape(self): """ Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added. """ for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] self.obj = self.obj.replace(v, k) ret...
[ "def", "unescape", "(", "self", ")", ":", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "_html_escape_table", ")", ":", "v", "=", "self", ".", "_html_escape_table", "[", "k", "]", "self", ".", "obj", "=", "self", ".", "obj", ".", "repl...
Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added.
[ "Within", "an", "interpolation", "evaluation", "or", "escaping", "remove", "HTML", "escaping", "that", "had", "been", "previously", "added", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1400-L1409