input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __eq__(self, other):
if isinstance(other, self.__class__):
return (self.glen == other.glen and
self.saddr == other.gaddr and
self.saddr == other.saddr)
elif (hasattr(other, "grp_address_length") and
hasattr(other, "grp_address") and
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, test, policer_index, is_ip6=False):
self._test = test
self._policer_index = policer_index
self._is_ip6 = is_ip6 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_vpp_config(self):
self._test.vapi.ip_punt_police(policer_index=self._policer_index,
is_ip6=self._is_ip6, is_add=True) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_vpp_config(self):
self._test.vapi.ip_punt_police(policer_index=self._policer_index,
is_ip6=self._is_ip6, is_add=False) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, test, rx_index, tx_index, nh_addr):
self._test = test
self._rx_index = rx_index
self._tx_index = tx_index
self._nh_addr = ip_address(nh_addr) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def encode(self):
return {"rx_sw_if_index": self._rx_index,
"tx_sw_if_index": self._tx_index, "nh": self._nh_addr} |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_vpp_config(self):
self._test.vapi.ip_punt_redirect(punt=self.encode(), is_add=True)
self._test.registry.register(self, self._test.logger) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_vpp_config(self):
self._test.vapi.ip_punt_redirect(punt=self.encode(), is_add=False) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_vpp_config(self):
is_ipv6 = True if self._nh_addr.version == 6 else False
return self._test.vapi.ip_punt_redirect_dump(
sw_if_index=self._rx_index, is_ipv6=is_ipv6) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def query_vpp_config(self):
if self.get_vpp_config():
return True
return False |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, test, nh, pmtu, table_id=0):
self._test = test
self.nh = nh
self.pmtu = pmtu
self.table_id = table_id |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_vpp_config(self):
self._test.vapi.ip_path_mtu_update(pmtu={'nh': self.nh,
'table_id': self.table_id,
'path_mtu': self.pmtu})
self._test.registry.register(self, self._test.logger)
return self |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def modify(self, pmtu):
self.pmtu = pmtu
self._test.vapi.ip_path_mtu_update(pmtu={'nh': self.nh,
'table_id': self.table_id,
'path_mtu': self.pmtu})
return self |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_vpp_config(self):
self._test.vapi.ip_path_mtu_update(pmtu={'nh': self.nh,
'table_id': self.table_id,
'path_mtu': 0}) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def query_vpp_config(self):
ds = list(self._test.vapi.vpp.details_iter(
self._test.vapi.ip_path_mtu_get))
for d in ds:
if self.nh == str(d.pmtu.nh) \
and self.table_id == d.pmtu.table_id \
and self.pmtu == d.pmtu.path_mtu:
return Tru... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def object_id(self):
return ("ip-path-mtu-%d-%s-%d" % (self.table_id,
self.nh,
self.pmtu)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def gaussian(data, mean, covariance):
"""!
@brief Calculates gaussian for dataset using specified mean (mathematical expectation) and variance or covariance in case
multi-dimensional data. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, sample, amount):
"""!
@brief Constructs EM initializer. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def initialize(self, init_type = ema_init_type.KMEANS_INITIALIZATION):
"""!
@brief Calculates initial parameters for EM algorithm: means and covariances using
specified strategy. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __calculate_initial_clusters(self, centers):
"""!
@brief Calculate Euclidean distance to each point from the each cluster.
@brief Nearest points are captured by according clusters and as a result clusters are updated. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __calculate_initial_covariances(self, initial_clusters):
covariances = []
for initial_cluster in initial_clusters:
if len(initial_cluster) > 1:
cluster_sample = [self.__sample[index_point] for index_point in initial_cluster]
covariances.append(numpy.c... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __initialize_random(self):
initial_means = [] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __initialize_kmeans(self):
initial_centers = kmeans_plusplus_initializer(self.__sample, self.__amount).initialize()
kmeans_instance = kmeans(self.__sample, initial_centers, ccore = True)
kmeans_instance.process() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self):
"""!
@brief Initializes EM observer. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_iterations(self):
"""!
@return (uint) Amount of iterations that were done by the EM algorithm. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_evolution_means(self):
"""!
@return (list) Mean of each cluster on each step of clustering. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_evolution_covariances(self):
"""!
@return (list) Covariance matrix (or variance in case of one-dimensional data) of each cluster on each step of clustering. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_evolution_clusters(self):
"""!
@return (list) Allocated clusters on each step of clustering. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def notify(self, means, covariances, clusters):
"""!
@brief This method is used by the algorithm to notify observer about changes where the algorithm
should provide new values: means, covariances and allocated clusters. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def show_clusters(clusters, sample, covariances, means, figure=None, display=True):
"""!
@brief Draws clusters and in case of two-dimensional dataset draws their ellipses.
@details Allocated figure by this method should be closed using `close()` method of this visualizer. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def close(figure):
"""!
@brief Closes figure object that was used or allocated by the visualizer. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def animate_cluster_allocation(data, observer, animation_velocity = 75, movie_fps = 1, save_movie = None):
"""!
@brief Animates clustering process that is performed by EM algorithm. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def init_frame():
return frame_generation(0) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def frame_generation(index_iteration):
figure.clf() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __draw_ellipses(figure, visualizer, clusters, covariances, means):
ax = figure.get_axes()[0] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __draw_ellipse(ax, x, y, angle, width, height, color):
if (width > 0.0) and (height > 0.0):
ax.plot(x, y, color=color, marker='x', markersize=6)
ellipse = patches.Ellipse((x, y), width, height, alpha=0.2, angle=-angle, linewidth=2, fill=True, zorder=2, color=color)
ax... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, data, amount_clusters, means=None, variances=None, observer=None, tolerance=0.00001, iterations=100):
"""!
@brief Initializes Expectation-Maximization algorithm for cluster analysis. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def process(self):
"""!
@brief Run clustering process of the algorithm. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_clusters(self):
"""!
@return (list) Allocated clusters where each cluster is represented by list of indexes of points from dataset,
for example, two cluster may have following representation [[0, 1, 4], [2, 3, 5, 6]]. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_centers(self):
"""!
@return (list) Corresponding centers (means) of clusters. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_covariances(self):
"""!
@return (list) Corresponding variances (or covariances in case of multi-dimensional data) of clusters. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_probabilities(self):
"""!
@brief Returns 2-dimensional list with belong probability of each object from data to cluster correspondingly,
where that first index is for cluster and the second is for point. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __erase_empty_clusters(self):
clusters, means, variances, pic, gaussians, rc = [], [], [], [], [], [] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __notify(self):
if self.__observer is not None:
self.__observer.notify(self.__means, self.__variances, self.__clusters) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __extract_clusters(self):
self.__clusters = [[] for _ in range(self.__amount_clusters)]
for index_point in range(len(self.__data)):
candidates = []
for index_cluster in range(self.__amount_clusters):
candidates.append((index_cluster, self.__rc[index_clust... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __log_likelihood(self):
likelihood = 0.0 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __probabilities(self, index_cluster, index_point):
divider = 0.0
for i in range(self.__amount_clusters):
divider += self.__pic[i] * self.__gaussians[i][index_point] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __expectation_step(self):
self.__gaussians = [ [] for _ in range(self.__amount_clusters) ]
for index in range(self.__amount_clusters):
self.__gaussians[index] = gaussian(self.__data, self.__means[index], self.__variances[index]) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __maximization_step(self):
self.__pic = []
self.__means = []
self.__variances = [] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __get_stop_condition(self):
for covariance in self.__variances:
if numpy.linalg.norm(covariance) == 0.0:
return True |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __update_covariance(self, means, rc, mc):
covariance = 0.0
for index_point in range(len(self.__data)):
deviation = numpy.array([self.__data[index_point] - means])
covariance += rc[index_point] * deviation.T.dot(deviation) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __update_mean(self, rc, mc):
mean = 0.0
for index_point in range(len(self.__data)):
mean += rc[index_point] * self.__data[index_point] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __normalize_probabilities(self):
for index_point in range(len(self.__data)):
probability = 0.0
for index_cluster in range(len(self.__clusters)):
probability += self.__rc[index_cluster][index_point] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __normalize_probability(self, index_point, probability):
if probability == 0.0:
return |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __verify_arguments(self):
"""!
@brief Verify input parameters for the algorithm and throw exception in case of incorrectness. |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __enter__(self):
"""
Syntax sugar which helps in celery tasks, cron jobs, and other scripts
Usage:
with Tenant.objects.get(schema_name='test') as tenant:
# run some code in tenant test
# run some code in previous tenant (public probably)
"""
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | async def handler(client, request):
if request.path == "/v6/challenge":
assert request.encode().decode() == CHALLENGE_REQUEST
response = http.HTTPResponse(200)
response.json = {
"challenge": "vaNgVZZH7gUse0y3t8Cksuln-TAVtvBmcD-ow59qp0E=",
"data": "dlL7ZBNSLmYo1hUlKYZiUA=="
}
return resp... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __exit__(self, exc_type, exc_val, exc_tb):
connection = connections[get_tenant_database_alias()]
connection.set_tenant(self._previous_tenant.pop()) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def activate(self):
"""
Syntax sugar that helps at django shell with fast tenant changing
Usage:
Tenant.objects.get(schema_name='test').activate()
"""
connection = connections[get_tenant_database_alias()]
connection.set_tenant(self) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def deactivate(cls):
"""
Syntax sugar, return to public schema
Usage:
test_tenant.deactivate()
# or simpler
Tenant.deactivate()
"""
connection = connections[get_tenant_database_alias()]
connection.set_schema_to_public() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def save(self, verbosity=1, *args, **kwargs):
connection = connections[get_tenant_database_alias()]
is_new = self.pk is None
has_schema = hasattr(connection, 'schema_name')
if has_schema and is_new and connection.schema_name != get_public_schema_name():
raise Exception("Can't... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def serializable_fields(self):
""" in certain cases the user model isn't serializable so you may want to only send the id """
return self |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _drop_schema(self, force_drop=False):
""" Drops the schema"""
connection = connections[get_tenant_database_alias()]
has_schema = hasattr(connection, 'schema_name')
if has_schema and connection.schema_name not in (self.schema_name, get_public_schema_name()):
raise Exceptio... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def pre_drop(self):
"""
This is a routine which you could override to backup the tenant schema before dropping.
:return:
""" |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def delete(self, force_drop=False, *args, **kwargs):
"""
Deletes this row. Drops the tenant's schema if the attribute
auto_drop_schema set to True.
"""
self._drop_schema(force_drop)
super().delete(*args, **kwargs) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def create_schema(self, check_if_exists=False, sync_schema=True,
verbosity=1):
"""
Creates the schema 'schema_name' for this tenant. Optionally checks if
the schema already exists before creating it. Returns true if the
schema was created, false otherwise.
"... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_primary_domain(self):
"""
Returns the primary domain of the tenant
"""
try:
domain = self.domains.get(is_primary=True)
return domain
except get_tenant_domain_model().DoesNotExist:
return None |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def reverse(self, request, view_name):
"""
Returns the URL of this tenant.
"""
http_type = 'https://' if request.is_secure() else 'http://'
domain = get_current_site(request).domain
url = ''.join((http_type, self.schema_name, '.', domain, reverse(view_name)))
r... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_tenant_type(self):
"""
Get the type of tenant. Will only work for multi type tenants
:return: str
"""
return getattr(self, settings.MULTI_TYPE_DATABASE_FIELD) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def save(self, *args, **kwargs):
# Get all other primary domains with the same tenant
domain_list = self.__class__.objects.filter(tenant=self.tenant, is_primary=True).exclude(pk=self.pk)
# If we have no primary domain yet, set as primary domain by default
self.is_primary = self.is_primar... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def addOperators(self, num, target):
"""
Adapted from https://leetcode.com/discuss/58614/java-standard-backtrace-ac-solutoin-short-and-clear
Algorithm:
1. DFS
2. Special handling for multiplication
3. Detect invalid number with leading 0's
:type num: str
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def dfs(self, num, target, pos, cur_str, cur_val, mul, ret):
if pos >= len(num):
if cur_val == target:
ret.append(cur_str)
else:
for i in xrange(pos, len(num)):
if i != pos and num[pos] == "0":
continue
nxt_val =... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def implementor(rpc_code, blocking=False):
"""
RPC implementation function.
"""
return partial(_add_implementor, rpc_code, blocking) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _add_implementor(rpc_code, blocking, fn):
# Validate the argument types.
if type(rpc_code) is not int:
raise TypeError("Expected int, got %r instead" % type(rpc_code))
if type(blocking) is not bool:
raise TypeError("Expected bool, got %r instead" % type(blocking))
if not callable(fn... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def rpc_bulk(orchestrator, audit_name, rpc_code, *arguments):
# Get the implementor for the RPC code.
# Raise NotImplementedError if it's not defined.
try:
method, blocking = rpcMap[rpc_code]
except KeyError:
raise NotImplementedError("RPC code not implemented: %r" % rpc_code)
# Th... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def rpc_send_message(orchestrator, audit_name, message):
# Enqueue the ACK message.
orchestrator.enqueue_msg(message) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, orchestrator):
"""
:param orchestrator: Orchestrator instance.
:type orchestrator: Orchestrator
"""
# Keep a reference to the Orchestrator.
self.__orchestrator = orchestrator
# Keep a reference to the global RPC map (it's faster this way).
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def orchestrator(self):
"""
:returns: Orchestrator instance.
:rtype: Orchestrator
"""
return self.__orchestrator |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def execute_rpc(self, audit_name, rpc_code, response_queue, args, kwargs):
"""
Honor a remote procedure call request from a plugin.
:param audit_name: Name of the audit requesting the call.
:type audit_name: str
:param rpc_code: RPC code.
:type rpc_code: int
:p... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _execute_rpc_implementor_background(self, context, audit_name, target,
response_queue, args, kwargs):
"""
Honor a remote procedure call request from a plugin,
from a background thread. Must only be used as the entry
point for said background... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def execute_rpc_implementor(self, audit_name, target, response_queue,
args, kwargs):
"""
Honor a remote procedure call request from a plugin.
:param audit_name: Name of the audit requesting the call.
:type audit_name: str
:param target: RPC imple... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, cost_withGradients):
super(CostModel, self).__init__()
self.cost_type = cost_withGradients
# --- Set-up evaluation cost
if self.cost_type is None:
self.cost_withGradients = constant_cost_withGradients
self.cost_type = 'Constant cost'
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self):
self.SOURCE_HTML_BASE_FOLDER_PATH = u"cameo_res\\source_html"
self.PARSED_RESULT_BASE_FOLDER_PATH = u"cameo_res\\parsed_result"
self.strWebsiteDomain = u"http://buzzorange.com/techorange"
self.dicSubCommandHandler = {
"index":self.downloadIndexPage,
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _cost_gp(self,x):
"""
Predicts the time cost of evaluating the function at x.
"""
m, _, _, _ = self.cost_model.predict_withGradients(x)
return np.exp(m) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getUseageMessage(self):
return ("- TECHORANGE -\n"
"useage:\n"
"index - download entry page of TECHORANGE \n"
"tag - download not obtained tag page \n"
"news [tag] - download not obtained news [of given tag] \n") |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _cost_gp_withGradients(self,x):
"""
Predicts the time cost and its gradient of evaluating the function at x.
"""
m, _, dmdx, _= self.cost_model.predict_withGradients(x)
return np.exp(m), np.exp(m)*dmdx |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getDriver(self):
chromeDriverExeFilePath = "cameo_res\\chromedriver.exe"
driver = webdriver.Chrome(chromeDriverExeFilePath)
return driver |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def update_cost_model(self, x, cost_x):
"""
Updates the GP used to handle the cost.
param x: input of the GP for the cost model.
param x_cost: values of the time cost at the input locations.
"""
if self.cost_type == 'evaluation_time':
cost_evals = np.log(np.... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def initDriver(self):
if self.driver is None:
self.driver = self.getDriver() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def quitDriver(self):
self.driver.quit()
self.driver = None |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def runSpider(self, lstSubcommand=None):
strSubcommand = lstSubcommand[0]
strArg1 = None
if len(lstSubcommand) == 2:
strArg1 = lstSubcommand[1]
self.initDriver() #init selenium driver
self.dicSubCommandHandler[strSubcommand](strArg1)
self.quitDriver() #quit se... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def downloadIndexPage(self, uselessArg1=None):
logging.info("download index page")
strIndexHtmlFolderPath = self.SOURCE_HTML_BASE_FOLDER_PATH + u"\\TECHORANGE"
if not os.path.exists(strIndexHtmlFolderPath):
os.mkdir(strIndexHtmlFolderPath) #mkdir source_html/TECHORANGE/
#科技報橘... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def downloadTagPag(self, uselessArg1=None):
logging.info("download tag page")
strTagHtmlFolderPath = self.SOURCE_HTML_BASE_FOLDER_PATH + u"\\TECHORANGE\\tag"
if not os.path.exists(strTagHtmlFolderPath):
os.mkdir(strTagHtmlFolderPath) #mkdir source_html/TECHORANGE/tag/
strTagW... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def limitStrLessThen128Char(self, strStr=None):
if len(strStr) > 128:
logging.info("limit str less then 128 char")
return strStr[:127] + u"_"
else:
return strStr |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def downloadNewsPage(self, strTagName=None):
if strTagName is None:
#未指定 tag
lstStrObtainedTagName = self.db.fetchallCompletedObtainedTagName()
for strObtainedTagName in lstStrObtainedTagName:
self.downloadNewsPageWithGivenTagName(strTagName=strObtainedTagName... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def downloadNewsPageWithGivenTagName(self, strTagName=None):
logging.info("download news page with tag %s"%strTagName)
strNewsHtmlFolderPath = self.SOURCE_HTML_BASE_FOLDER_PATH + u"\\TECHORANGE\\news"
if not os.path.exists(strNewsHtmlFolderPath):
os.mkdir(strNewsHtmlFolderPath) #mkdi... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def write():
try:
p = round(weather.pressure(),2)
c = light.light()
print('{"light": '+str(c)+', "pressure": '+str(p)+' }')
except KeyboardInterrupt:
pass |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def signal_handler_mapping(self):
"""A dict mapping (signal number) -> (a method handling the signal)."""
# Could use an enum here, but we never end up doing any matching on the specific signal value,
# instead just iterating over the registered signals to set handlers, so a dict is probably
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self):
self._ignore_sigint_lock = threading.Lock()
self._threads_ignoring_sigint = 0
self._ignoring_sigint_v2_engine = False |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _check_sigint_gate_is_correct(self):
assert (
self._threads_ignoring_sigint >= 0
), "This should never happen, someone must have modified the counter outside of SignalHandler." |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.