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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7ed68b135fae7055a1df0bce1a986f0d8ac261d1 | 1,278 | py | Python | hackerrank/greedy/easy/luck_balance.py | johnklee/algprac | 51a7c872806aec261c5e3db6cbac47ec34516b4d | [
"Apache-2.0"
] | null | null | null | hackerrank/greedy/easy/luck_balance.py | johnklee/algprac | 51a7c872806aec261c5e3db6cbac47ec34516b4d | [
"Apache-2.0"
] | null | null | null | hackerrank/greedy/easy/luck_balance.py | johnklee/algprac | 51a7c872806aec261c5e3db6cbac47ec34516b4d | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python
import math
import os
import random
import re
import sys
r'''
https://www.hackerrank.com/challenges/luck-balance/problem
'''
# Complete the luckBalance function below.
def luckBalance(n, k, contests):
luck_sum = 0
important_game_luck_list = []
for l, t in contests:
if t == 0:
luck_sum += l
else:
important_game_luck_list.append(l)
# Sorting in descending order
important_game_luck_list = sorted(important_game_luck_list, reverse=True)
# Add up all luck in losing game
for i in range(min(k, len(important_game_luck_list))):
luck_sum += important_game_luck_list[i]
# Minus back all luck in winning game
if k < len(important_game_luck_list):
for i in important_game_luck_list[k:]:
luck_sum -= i
return luck_sum
import unittest
class FAT(unittest.TestCase):
def setUp(self):
pass
def test_01(self):
self.assertEqual(luckBalance(3, 2, [(5, 1), (1, 1), (4, 0)]), 10)
self.assertEqual(luckBalance(3, 1, [(5, 1), (1, 1), (4, 0)]), 8)
def test_02(self):
real = luckBalance(6, 3, [(5, 1), (2, 1), (1, 1), (8, 1), (10, 0), (5, 0)])
self.assertEqual(real, 29, 'Expect:29; Real:{}'.format(real))
| 25.56 | 83 | 0.621283 | 193 | 1,278 | 3.953368 | 0.419689 | 0.136304 | 0.178244 | 0.220183 | 0.116645 | 0.081258 | 0 | 0 | 0 | 0 | 0 | 0.045549 | 0.244131 | 1,278 | 49 | 84 | 26.081633 | 0.744306 | 0.122066 | 0 | 0 | 0 | 0 | 0.017127 | 0 | 0 | 0 | 0 | 0 | 0.096774 | 1 | 0.129032 | false | 0.032258 | 0.419355 | 0 | 0.612903 | 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 | 0 | 0 | 0 | 2 |
7edd1979a3b1be28d9c0d5d26e5f431ea582aaeb | 9,520 | py | Python | python/smqtk/representation/descriptor_element/__init__.py | mikiec84/SMQTK | 8d0bbfe7ba89ada28299fecf0bee8ceb7863ccef | [
"BSD-3-Clause"
] | null | null | null | python/smqtk/representation/descriptor_element/__init__.py | mikiec84/SMQTK | 8d0bbfe7ba89ada28299fecf0bee8ceb7863ccef | [
"BSD-3-Clause"
] | 3 | 2021-09-08T02:17:49.000Z | 2022-03-12T00:40:33.000Z | python/smqtk/representation/descriptor_element/__init__.py | mikiec84/SMQTK | 8d0bbfe7ba89ada28299fecf0bee8ceb7863ccef | [
"BSD-3-Clause"
] | null | null | null | import abc
import numpy
from collections import defaultdict
from smqtk.representation import SmqtkRepresentation
from smqtk.utils.dict import merge_dict
from smqtk.utils.plugin import Pluggable
from smqtk.utils.parallel import parallel_map
from ._io import elements_to_matrix
def _uuid_and_vector_from_descriptor(descriptor):
"""
Given a descriptor, return a tuple containing the UUID and associated
vector for that descriptor
:param descriptor: The descriptor to process.
:type descriptor: smqtk.representation.descriptor_element.DescriptorElement
:return: Tuple containing the UUID and associated vector for the given
descriptor
:rtype: tuple[collections.Hashable, numpy.ndarray]
"""
return (descriptor.uuid(), descriptor.vector())
class DescriptorElement (SmqtkRepresentation, Pluggable):
"""
Abstract descriptor vector container.
This structure supports implementations that cache descriptor vectors on a
per-UUID basis.
UUIDs must maintain unique-ness when transformed into a string.
Descriptor element equality based on shared descriptor type and vector
equality. Two descriptor vectors that are generated by different types of
descriptor generator should not be considered the same (though, this may be
up for discussion).
Stored vectors should be effectively immutable.
"""
def __init__(self, type_str, uuid):
"""
Initialize a new descriptor element.
:param type_str: Type of descriptor. This is usually the name of the
content descriptor that generated this vector.
:type type_str: str
:param uuid: Unique ID reference of the descriptor.
:type uuid: collections.Hashable
"""
super(DescriptorElement, self).__init__()
self._type_label = type_str
self._uuid = uuid
def __hash__(self):
return hash(self.uuid())
def __eq__(self, other):
if isinstance(other, DescriptorElement):
return numpy.array_equal(self.vector(), other.vector())
return False
def __ne__(self, other):
return not (self == other)
def __repr__(self):
return "%s{type: %s, uuid: %s}" % (self.__class__.__name__, self.type(),
self.uuid())
def __getstate__(self):
return {
"_type_label": self._type_label,
"_uuid": self._uuid,
}
def __setstate__(self, state):
self._type_label = state['_type_label']
self._uuid = state['_uuid']
@classmethod
def get_default_config(cls):
"""
Generate and return a default configuration dictionary for this class.
This will be primarily used for generating what the configuration
dictionary would look like for this class without instantiating it.
By default, we observe what this class's constructor takes as arguments,
aside from the first two assumed positional arguments, turning those
argument names into configuration dictionary keys.
If any of those arguments have defaults, we will add those values into
the configuration dictionary appropriately.
The dictionary returned should only contain JSON compliant value types.
It is not be guaranteed that the configuration dictionary returned
from this method is valid for construction of an instance of this class.
:return: Default configuration dictionary for the class.
:rtype: dict
"""
# similar to parent impl, except we remove the ``type_str`` and ``uuid``
# configuration parameters as they are to be specified at runtime.
dc = super(DescriptorElement, cls).get_default_config()
# These parameters must be specified at construction time.
del dc['type_str'], dc['uuid']
return dc
# noinspection PyMethodOverriding
@classmethod
def from_config(cls, config_dict, type_str, uuid, merge_default=True):
"""
Instantiate a new instance of this class given the desired type, uuid,
and JSON-compliant configuration dictionary.
:param type_str: Type of descriptor. This is usually the name of the
content descriptor that generated this vector.
:type type_str: str
:param uuid: Unique ID reference of the descriptor.
:type uuid: collections.Hashable
:param config_dict: JSON compliant dictionary encapsulating
a configuration.
:type config_dict: dict
:param merge_default: Merge the given configuration on top of the
default provided by ``get_default_config``.
:type merge_default: bool
:return: Constructed instance from the provided config.
:rtype: DescriptorElement
"""
c = {}
merge_dict(c, config_dict)
c['type_str'] = type_str
c['uuid'] = uuid
return super(DescriptorElement, cls).from_config(c, merge_default)
def uuid(self):
"""
:return: Unique ID for this vector.
:rtype: collections.Hashable
"""
return self._uuid
def type(self):
"""
:return: Type label type of the DescriptorGenerator that generated this
vector.
:rtype: str
"""
return self._type_label
@classmethod
def _get_many_vectors(cls, descriptors):
"""
Internal method to be overridden by subclasses to return many vectors
associated with given descriptors.
:note: Returned vectors are *not* guaranteed to be returned in the
order they are requested. Missing vectors may be returned as None
or omitted entirely from results. The wrapper function
`get_many_vectors` handles re-ordering as necessary and insertion
of None for missing values.
:param descriptors: Iterable of descriptors to query for.
:type descriptors: collections.Iterable[
smqtk.representation.descriptor_element.DescriptorElement]
:return: Iterator of tuples containing the descriptor uuid and the
vector associated with the given descriptors or None if the
descriptor has no associated vector
:rtype: collections.Iterable[
tuple[collections.Hashable, Union[numpy.ndarray, None]]]
"""
for uuid_vector_pair in parallel_map(
_uuid_and_vector_from_descriptor, descriptors,
name='retrieve_vectors'):
yield uuid_vector_pair
@classmethod
def get_many_vectors(cls, descriptors):
"""
Get an iterator over vectors associated with given descriptors.
:note: Most subclasses should override internal method
`_get_many_vectors` rather than this external wrapper function. If
a subclass does override this classmethod, it is responsible for
appropriately handling any valid DescriptorElement, regardless of
subclass.
:param descriptors: Iterable of descriptors to query for.
:type descriptors: collections.Iterable[
smqtk.representation.descriptor_element.DescriptorElement]
:return: Iterable of vectors associated with the given descriptors or
None if the descriptor has no associated vector. Results are
returned in the order that descriptors were given.
:rtype: collections.Iterable[Union[numpy.ndarray, None]]
"""
batch_dictionary = defaultdict(list)
uuid_indices = {}
index = -1
for index, descriptor_ in enumerate(descriptors):
# Divide descriptors up into batches based on their type, since
# each DescriptorElement subclass knows best how to optimally
# retrieve vectors of its own type.
batch_dictionary[type(descriptor_)].append(descriptor_)
# Keep track of the order of descriptors to ensure that we return
# vectors in the requested order after batching them out.
uuid_indices[descriptor_.uuid()] = index
# Default to None, since _get_many_vectors implementations can ignore
# any descriptors that cannot be retrieved
ordered_vectors = [None] * (index + 1)
# Retrieve all the vectors for a given type of descriptor in a single
# batch
for cls, descriptor_batch in batch_dictionary.items():
for uuid, vector in cls._get_many_vectors(descriptor_batch):
ordered_vectors[uuid_indices[uuid]] = vector
return ordered_vectors
###
# Abstract methods
#
@abc.abstractmethod
def has_vector(self):
"""
:return: Whether or not this container current has a descriptor vector
stored.
:rtype: bool
"""
@abc.abstractmethod
def vector(self):
"""
:return: Get the stored descriptor vector as a numpy array. This returns
None of there is no vector stored in this container.
:rtype: numpy.ndarray or None
"""
@abc.abstractmethod
def set_vector(self, new_vec):
"""
Set the contained vector.
If this container already stores a descriptor vector, this will
overwrite it.
:param new_vec: New vector to contain.
:type new_vec: numpy.ndarray
:returns: Self.
:rtype: DescriptorMemoryElement
"""
| 35.390335 | 80 | 0.661555 | 1,107 | 9,520 | 5.556459 | 0.254743 | 0.012518 | 0.013656 | 0.017558 | 0.186474 | 0.177695 | 0.154772 | 0.141115 | 0.126809 | 0.126809 | 0 | 0.000291 | 0.277941 | 9,520 | 268 | 81 | 35.522388 | 0.89453 | 0.578151 | 0 | 0.093333 | 0 | 0 | 0.030157 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.226667 | false | 0 | 0.106667 | 0.053333 | 0.506667 | 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 | 0 | 1 | 0 | 0 | 2 |
7edf76b6600b05a8c9e3c83e36e5b4783fedb977 | 10,518 | py | Python | pdsf_py2/tests/test_weaver.py | probablytom/pydysofu | 6b760f288fb4305561e885e54652cfb11c80ef14 | [
"MIT"
] | null | null | null | pdsf_py2/tests/test_weaver.py | probablytom/pydysofu | 6b760f288fb4305561e885e54652cfb11c80ef14 | [
"MIT"
] | 2 | 2017-11-17T16:59:40.000Z | 2018-04-22T11:35:51.000Z | pdsf_py2/tests/test_weaver.py | probablytom/pydysofu | 6b760f288fb4305561e885e54652cfb11c80ef14 | [
"MIT"
] | 1 | 2017-11-17T16:33:04.000Z | 2017-11-17T16:33:04.000Z | import unittest
from mock import Mock
import pydysofu as fm
from pydysofu.core_fuzzers import *
from example_workflow import ExampleWorkflow
class FuzziMossWeaverTest(unittest.TestCase):
def setUp(self):
self.environment = list()
self.target = ExampleWorkflow(self.environment)
def test_identity(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: identity
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEquals([1, 2, 3], self.environment)
def test_remove_last_step(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: remove_last_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1, 2], self.environment)
def test_remove_last_step_twice(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: remove_last_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.target.method_for_fuzzing()
self.assertEqual([1, 2, 1, 2], self.environment)
def test_duplicate_last_step(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: duplicate_last_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1, 2, 3, 3], self.environment)
def test_remove_random_step(self):
fm.pydysofu_random.sample = Mock(side_effect=[[1]])
test_advice = {
ExampleWorkflow.method_for_fuzzing: remove_random_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1, 3], self.environment)
def test_remove__random_step_twice(self):
fm.pydysofu_random.sample = Mock(side_effect=[[1], [2]])
test_advice = {
ExampleWorkflow.method_for_fuzzing: remove_random_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.target.method_for_fuzzing()
self.assertEqual([1, 3, 1, 2], self.environment)
def test_replace_all_steps_with_pass_in_random_sequence(self):
fm.pydysofu_random.sample = Mock(side_effect=[[0], [1], [2]])
test_advice = {
ExampleWorkflow.method_for_fuzzing:
in_sequence([remove_random_step, remove_random_step, remove_random_step])
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([], self.environment)
def test_remove_all_steps(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: in_sequence([remove_last_step, remove_last_step, remove_last_step])
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([], self.environment)
def test_shuffle_steps(self):
def mock_random_shuffle(iterable):
iterable[0], iterable[1], iterable[2] = iterable[2], iterable[0], iterable[1]
fm.pydysofu_random.shuffle = Mock(side_effect=mock_random_shuffle)
test_advice = {
ExampleWorkflow.method_for_fuzzing: shuffle_steps
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([3, 1, 2], self.environment)
def test_swap_if_blocks(self):
test_advice = {
ExampleWorkflow.method_containing_if: swap_if_blocks
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if()
self.assertEqual([2], self.environment)
def test_choose_from(self):
fm.pydysofu_random.uniform = Mock(side_effect=[0.75, 0.75])
test_advice = {
ExampleWorkflow.method_for_fuzzing: choose_from([(0.5, identity), (0.5, remove_last_step)])
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.target.method_for_fuzzing()
self.assertEqual([1, 2, 1, 2], self.environment)
def test_in_sequence(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: in_sequence([remove_last_step, remove_last_step])
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1], self.environment)
def test_on_condition_that(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: on_condition_that(True, remove_last_step)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1, 2], self.environment)
def test_on_condition_that_with_function(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: on_condition_that(lambda: False, remove_last_step)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEqual([1, 2, 3], self.environment)
def test_replace_condition(self):
test_advice = {
ExampleWorkflow.method_containing_if: replace_condition_with('1 is 2')
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if()
self.assertEquals([2], self.environment)
def test_replace_condition_with_function(self):
test_advice = {
ExampleWorkflow.method_containing_if: replace_condition_with(lambda: False)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if()
self.assertEquals([2], self.environment)
def test_replace_condition_with_literal(self):
test_advice = {
ExampleWorkflow.method_containing_if: replace_condition_with(False)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if()
self.assertEquals([2], self.environment)
pass
def test_make_nested_fuzzing_call(self):
test_advice = {
ExampleWorkflow.make_nested_fuzzing_call: remove_last_step,
ExampleWorkflow.nested_method_call: remove_last_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.make_nested_fuzzing_call()
self.assertEquals([1, 3], self.environment)
def test_replace_iterator(self):
test_advice = {
ExampleWorkflow.method_containing_iterator: replace_for_iterator_with([3, 2, 1])
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_iterator()
self.assertEquals([3, 2, 1], self.environment)
def test_apply_fuzzer_to_nested_statements(self):
test_advice = {
ExampleWorkflow.method_containing_for_and_nested_try:
recurse_into_nested_steps(remove_last_step, target_structures={ast.For, ast.TryExcept})
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_for_and_nested_try()
self.assertEquals([0, 1, 2, 7], self.environment)
pass
def test_mangled_function_excluding_control_structures(self):
test_advice = {
ExampleWorkflow.method_containing_if_followed_by_for:
filter_steps(exclude_control_structures({ast.For}), remove_last_step)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if_followed_by_for()
self.assertEquals([1, 2], self.environment)
def test_mangled_function_including_control_structures(self):
test_advice = {
ExampleWorkflow.method_containing_if_followed_by_for:
filter_steps(include_control_structures({ast.For}), remove_last_step)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_containing_if_followed_by_for()
self.assertEquals([1], self.environment)
def test_mangled_function_invert_filter(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing_that_returns_4:
filter_steps(invert(choose_last_step), replace_steps_with_pass)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
result = self.target.method_for_fuzzing_that_returns_4()
self.assertEquals(4, result)
self.assertEquals(self.environment, [])
def test_mangled_function_invert_invert_filter(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing_that_returns_4:
filter_steps(invert(invert(choose_last_step)), replace_steps_with_pass)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
result = self.target.method_for_fuzzing_that_returns_4()
self.assertEquals(None, result)
self.assertEquals(self.environment, [1, 2, 3])
def test_fuzzing_class_method(self):
test_advice = {
ExampleWorkflow.example_class_method:
remove_last_step
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
result = self.target.example_class_method()
self.assertEquals(None, result)
def test_insert_code(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: insert_steps(0, 'self.environment.append(4)')
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEquals(self.environment, [4, 1, 2, 3])
def test_fuzz_specific_object(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing:
filter_context(
[(lambda context: hasattr(context, 'name') and context.name == 'a workflow', remove_last_step)]
)
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.target.method_for_fuzzing()
self.assertEquals(self.environment, [1, 2, 3])
self.target.name = 'a workflow'
self.target.method_for_fuzzing()
self.assertEquals(self.environment, [1, 2, 3, 1, 2])
def test_bad_fuzz(self):
test_advice = {
ExampleWorkflow.method_for_fuzzing: replace_steps_with(0, 3, '4bad_syntax')
}
fm.fuzz_clazz(ExampleWorkflow, test_advice)
self.assertRaises(StandardError, self.target.method_for_fuzzing)
if __name__ == '__main__':
unittest.main()
| 31.776435 | 115 | 0.670945 | 1,203 | 10,518 | 5.490441 | 0.095594 | 0.084784 | 0.096896 | 0.11022 | 0.796669 | 0.764875 | 0.716427 | 0.63028 | 0.612112 | 0.571537 | 0 | 0.012503 | 0.239589 | 10,518 | 330 | 116 | 31.872727 | 0.813328 | 0 | 0 | 0.461538 | 0 | 0 | 0.007131 | 0.002472 | 0 | 0 | 0 | 0 | 0.132479 | 1 | 0.128205 | false | 0.021368 | 0.021368 | 0 | 0.153846 | 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 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7ee1cea292fb458c52322f948a80cf00ff833b01 | 176 | py | Python | tkgeom/__init__.py | ezsolti/TKworkshop | d6e0d6f67cd21b58238ab1651256c9a1ce474ff1 | [
"MIT"
] | null | null | null | tkgeom/__init__.py | ezsolti/TKworkshop | d6e0d6f67cd21b58238ab1651256c9a1ce474ff1 | [
"MIT"
] | null | null | null | tkgeom/__init__.py | ezsolti/TKworkshop | d6e0d6f67cd21b58238ab1651256c9a1ce474ff1 | [
"MIT"
] | null | null | null | __package__ = 'tkgeom'
__title__ = 'tkgeom'
__description__ = '2D geometry module as an example for the TK workshop'
__copyright__ = '2019, Zs. Elter'
__version__ = '1.0.0'
| 19.555556 | 72 | 0.727273 | 23 | 176 | 4.695652 | 0.913043 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054422 | 0.164773 | 176 | 8 | 73 | 22 | 0.680272 | 0 | 0 | 0 | 0 | 0 | 0.477273 | 0 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7eefe9b70bf2e476fb8c24ccf757773ec8b67549 | 383 | py | Python | powerline/matchers/vim/plugin/commandt.py | MrFishFinger/powerline | 361534bafecf836e100eaff257c93eb4805f48db | [
"MIT"
] | 11,435 | 2015-01-01T03:32:34.000Z | 2022-03-31T20:39:05.000Z | powerline/matchers/vim/plugin/commandt.py | ritiek/powerline | 82c1373ba0b424c57e8c12cb5f6f1a7ee3829c27 | [
"MIT"
] | 879 | 2015-01-02T11:59:30.000Z | 2022-03-24T09:52:17.000Z | powerline/matchers/vim/plugin/commandt.py | ritiek/powerline | 82c1373ba0b424c57e8c12cb5f6f1a7ee3829c27 | [
"MIT"
] | 1,044 | 2015-01-05T22:37:53.000Z | 2022-03-17T19:43:16.000Z | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
from powerline.bindings.vim import vim_getbufoption, buffer_name
def commandt(matcher_info):
name = buffer_name(matcher_info)
return (
vim_getbufoption(matcher_info, 'filetype') == 'command-t'
or (name and os.path.basename(name) == b'GoToFile')
)
| 25.533333 | 84 | 0.775457 | 52 | 383 | 5.442308 | 0.653846 | 0.116608 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002959 | 0.117493 | 383 | 14 | 85 | 27.357143 | 0.83432 | 0.070496 | 0 | 0 | 0 | 0 | 0.070621 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.555556 | 0.111111 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
7ef1af37ee7131adc61cc8f8405e7e6caff77fbc | 69 | py | Python | WEEKS/CD_Sata-Structures/_RESOURCES/python-prac/mini-scripts/Python_String_ljust()_1.txt.py | webdevhub42/Lambda | b04b84fb5b82fe7c8b12680149e25ae0d27a0960 | [
"MIT"
] | 5 | 2021-06-02T23:44:25.000Z | 2021-12-27T16:21:57.000Z | WEEKS/CD_Sata-Structures/_RESOURCES/python-prac/mini-scripts/Python_String_ljust()_1.txt.py | webdevhub42/Lambda | b04b84fb5b82fe7c8b12680149e25ae0d27a0960 | [
"MIT"
] | 22 | 2021-05-31T01:33:25.000Z | 2021-10-18T18:32:39.000Z | WEEKS/CD_Sata-Structures/_RESOURCES/python-prac/mini-scripts/Python_String_ljust()_1.txt.py | webdevhub42/Lambda | b04b84fb5b82fe7c8b12680149e25ae0d27a0960 | [
"MIT"
] | 3 | 2021-06-19T03:37:47.000Z | 2021-08-31T00:49:51.000Z | txt = "banana"
x = txt.ljust(20)
print(x, "is my favorite fruit.")
| 11.5 | 33 | 0.623188 | 12 | 69 | 3.583333 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035714 | 0.188406 | 69 | 5 | 34 | 13.8 | 0.732143 | 0 | 0 | 0 | 0 | 0 | 0.391304 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 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 | 0 | 0 | 2 |
7d057a59fb001f5f1abe0ba471cb9906cc6c9863 | 2,817 | py | Python | add_new_group.py | AnnaWyszomirska/test | 45b7b441cfb4924ca99910d3ee13893da1c7fcba | [
"Apache-2.0"
] | null | null | null | add_new_group.py | AnnaWyszomirska/test | 45b7b441cfb4924ca99910d3ee13893da1c7fcba | [
"Apache-2.0"
] | null | null | null | add_new_group.py | AnnaWyszomirska/test | 45b7b441cfb4924ca99910d3ee13893da1c7fcba | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
from selenium.webdriver.chrome.webdriver import WebDriver
from group import Group
import unittest
def is_alert_present(wd):
try:
wd.switch_to_alert().text
return True
except:
return False
class test_add_new_group (unittest.TestCase):
def setUp(self):
self.wd = WebDriver(executable_path="C:\\chromedriver_win32\\chromedriver.exe")
self.wd.implicitly_wait(60)
def open_homepage(self, wd):
wd.get("http://localhost/addressbook/addressbook/")
def login(self, wd, username, password):
wd.find_element_by_name("user").click()
wd.find_element_by_name("user").clear()
wd.find_element_by_name("user").send_keys(username)
wd.find_element_by_name("pass").click()
wd.find_element_by_name("pass").clear()
wd.find_element_by_name("pass").send_keys(password)
wd.find_element_by_xpath("//form[@id='LoginForm']/input[3]").click()
def open_group_page(self, wd):
wd.find_element_by_link_text("grupy").click()
def add_new_group(self, wd, group):
wd.find_element_by_name("new").click()
wd.find_element_by_name("group_name").click()
wd.find_element_by_name("group_name").clear()
wd.find_element_by_name("group_name").send_keys(group.header)
wd.find_element_by_name("group_header").click()
wd.find_element_by_name("group_header").clear()
wd.find_element_by_name("group_header").send_keys(group.name)
wd.find_element_by_name("group_footer").click()
wd.find_element_by_name("group_footer").clear()
wd.find_element_by_name("group_footer").send_keys(group.footer)
# submit group creation
wd.find_element_by_name("submit").click()
def return_to_group_page(self, wd):
wd.find_element_by_link_text("group page").click()
def logout(self, wd):
wd.find_element_by_link_text("Wyloguj się").click()
def test_add_full_group(self):
success = True
wd = self.wd
self.open_homepage(wd)
self.login(wd, username="admin", password="secret")
self.open_group_page(wd)
self.add_new_group(wd, Group(header="New group", name="New group", footer="New group"))
self.return_to_group_page(wd)
self.logout(wd)
self.assertTrue(success)
def test_add_empty_group(self):
success = True
wd = self.wd
self.open_homepage(wd)
self.login(wd, username="admin", password="secret")
self.open_group_page(wd)
self.add_new_group(wd, Group(header="", name="", footer=""))
self.return_to_group_page(wd)
self.logout(wd)
self.assertTrue(success)
def tearDown(self):
self.wd.quit()
if __name__ == '__main__':
unittest.main()
| 35.2125 | 95 | 0.662052 | 392 | 2,817 | 4.431122 | 0.214286 | 0.072539 | 0.157168 | 0.181347 | 0.582038 | 0.542314 | 0.451353 | 0.317214 | 0.262522 | 0.262522 | 0 | 0.002674 | 0.203408 | 2,817 | 79 | 96 | 35.658228 | 0.77139 | 0.015264 | 0 | 0.246154 | 0 | 0 | 0.119451 | 0.025983 | 0 | 0 | 0 | 0 | 0.030769 | 1 | 0.169231 | false | 0.092308 | 0.046154 | 0 | 0.261538 | 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 | 0 | 0 | 0 | 2 |
7d06fe7ac919f2b4e7d25bf0fb5436d1047d7f35 | 1,393 | py | Python | scripts_Utility/configure_training_subjects.py | mcarlosfr/Data-digging | 6e9dc5db6f6125316616c4b04ae5fc4223826a25 | [
"MIT"
] | 40 | 2016-05-17T10:53:28.000Z | 2022-02-08T05:02:21.000Z | scripts_Utility/configure_training_subjects.py | mcarlosfr/Data-digging | 6e9dc5db6f6125316616c4b04ae5fc4223826a25 | [
"MIT"
] | 29 | 2016-03-17T03:17:03.000Z | 2020-10-01T17:27:59.000Z | scripts_Utility/configure_training_subjects.py | mcarlosfr/Data-digging | 6e9dc5db6f6125316616c4b04ae5fc4223826a25 | [
"MIT"
] | 34 | 2015-12-04T15:18:12.000Z | 2021-08-13T13:35:49.000Z | from panoptes_client import Panoptes, Workflow, SubjectSet
###################################
### Training Subject Configuration Script
# Note: in addition to running this script, a Zoo team member must
# also configure Caesar and set workflow retirement to `never_retire`
# Input Parameters
puser = <ZOONIVERSE_USERNAME>
ppswd = <ZOONIVERSE_PASSWORD>
workflowid = 999999
subjsetids = [888888, 777777]
# Define training chances according to your needs.
chances = (10 * [0.5]) + (40 * [0.2]) + (50 * [0.1])
default_chance = 0.05
# If training subject metadata needs editing, then enable.
edit_metadata = False
###################################
Panoptes.connect(username=puser, password=ppswd)
w = Workflow.find(workflowid)
w.configuration['training_set_ids'] = subjsetids
w.configuration['training_default_chance'] = default_chance
w.configuration['training_chances'] = chances
w.configuration['subject_queue_page_size'] = 4
w.save()
if edit_metadata:
new_metadata = {"#training_subject": "true"}
for ssid in subjsetids:
subject_set = SubjectSet.find(ssid)
print('Editing metadata for Subject Set #{0}: {1}'.format
(subject_set.raw['id'], subject_set.raw['display_name']))
for subject in subject_set.subjects:
for key, value in new_metadata.items():
subject.metadata[key]=value
subject.save()
| 30.282609 | 71 | 0.677674 | 169 | 1,393 | 5.443787 | 0.508876 | 0.054348 | 0.071739 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.031142 | 0.170136 | 1,393 | 45 | 72 | 30.955556 | 0.764706 | 0.210337 | 0 | 0 | 0 | 0 | 0.151812 | 0.045054 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.08 | 0.04 | null | null | 0.04 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
7d1679905ffe45718eb7b3f140911ada8f549022 | 1,311 | py | Python | jj/middlewares/_base_middleware.py | TeoDV/jj | a58d91ad7b37ba3115daea4890190abede8f3353 | [
"Apache-2.0"
] | null | null | null | jj/middlewares/_base_middleware.py | TeoDV/jj | a58d91ad7b37ba3115daea4890190abede8f3353 | [
"Apache-2.0"
] | null | null | null | jj/middlewares/_base_middleware.py | TeoDV/jj | a58d91ad7b37ba3115daea4890190abede8f3353 | [
"Apache-2.0"
] | null | null | null | from typing import Type, Union
from ..apps import AbstractApp
from ..handlers import HandlerFunction
from ._abstract_middleware import AbstractMiddleware
from ._middleware_type import MiddlewareType
__all__ = ("BaseMiddleware", "AppOrHandler",)
AppOrHandler = Union[Type[AbstractApp], HandlerFunction]
class BaseMiddleware(AbstractMiddleware):
def on_app(self, app: Type[AbstractApp]) -> None:
pass
def on_handler(self, handler: HandlerFunction) -> None:
pass
def _call_hooks(self, app_or_handler: AppOrHandler) -> None:
if isinstance(app_or_handler, type) and issubclass(app_or_handler, AbstractApp):
return self.on_app(app_or_handler)
return self.on_handler(app_or_handler)
def _register_middleware(self,
app_or_handler: AppOrHandler, middleware: MiddlewareType) -> None:
old_middlewares = self._resolver.get_attribute("middlewares", app_or_handler, [])
new_middlewares = old_middlewares + [middleware]
self._resolver.register_attribute("middlewares", new_middlewares, app_or_handler)
def __call__(self, app_or_handler: AppOrHandler) -> AppOrHandler:
self._call_hooks(app_or_handler)
self._register_middleware(app_or_handler, self._do)
return app_or_handler
| 36.416667 | 95 | 0.731503 | 148 | 1,311 | 6.094595 | 0.27027 | 0.066519 | 0.159645 | 0.053215 | 0.093126 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.186117 | 1,311 | 35 | 96 | 37.457143 | 0.845361 | 0 | 0 | 0.08 | 0 | 0 | 0.036613 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.08 | 0.2 | 0 | 0.56 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
7d2101170a88fb621f8413a8182e367adbd7fbcf | 1,118 | py | Python | src/headers.py | gupta-siddhartha/MYTH | 4a57536ba91e77687fa86e714c06821b275fef7a | [
"MIT"
] | null | null | null | src/headers.py | gupta-siddhartha/MYTH | 4a57536ba91e77687fa86e714c06821b275fef7a | [
"MIT"
] | null | null | null | src/headers.py | gupta-siddhartha/MYTH | 4a57536ba91e77687fa86e714c06821b275fef7a | [
"MIT"
] | null | null | null | #=================================================================
# Useful paths for executing the MYTH
#
# Written by Siddhartha Gupta
# contact: gsiddhartha@uchicago.edu
#
# Last modified on 17 July 2020
#=================================================================
import os
import numpy as np
import readfile
import tools
import ytrendering
import sys
CodeInfo ="\
# ==================================================================\n\
# =============== M Y T H ==================\n\
# ==== Multipurpose YT-rendering code for Hydro-simulations ======\n\
# ==================================================================\n\
# =============== Author: Siddhartha Gupta ==================\n\
# =============== Last modified on 15.07.2020 ==================\n\
# ==================================================================\n"
Completion ="\
# ==================================================================\n\
# ======= Thank you for compiling yt using M Y T H ==========\n\
# ==================================================================\n"
| 36.064516 | 71 | 0.297853 | 76 | 1,118 | 4.381579 | 0.644737 | 0.018018 | 0.084084 | 0.024024 | 0.03003 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014418 | 0.131485 | 1,118 | 30 | 72 | 37.266667 | 0.328527 | 0.235242 | 0 | 0.277778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
7d3941a08ac6ab9d52a0cf0b2d2bcd7ba788a404 | 899 | py | Python | plugins/syslog_forwarder/komand_syslog_forwarder/connection/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 46 | 2019-06-05T20:47:58.000Z | 2022-03-29T10:18:01.000Z | plugins/syslog_forwarder/komand_syslog_forwarder/connection/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 386 | 2019-06-07T20:20:39.000Z | 2022-03-30T17:35:01.000Z | plugins/syslog_forwarder/komand_syslog_forwarder/connection/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 43 | 2019-07-09T14:13:58.000Z | 2022-03-28T12:04:46.000Z | # GENERATED BY KOMAND SDK - DO NOT EDIT
import komand
import json
class Input:
HOST = "host"
PORT = "port"
TRANSPORT = "transport"
class ConnectionSchema(komand.Input):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"host": {
"type": "string",
"title": "Host",
"description": "Syslog Host",
"order": 1
},
"port": {
"type": "integer",
"title": "Port",
"description": "Syslog Port",
"default": 514,
"order": 2
},
"transport": {
"type": "string",
"title": "Transport",
"description": "Protocol Transport",
"enum": [
"TCP",
"UDP"
],
"order": 3
}
},
"required": [
"host",
"port",
"transport"
]
}
""")
def __init__(self):
super(self.__class__, self).__init__(self.schema)
| 17.288462 | 57 | 0.493882 | 80 | 899 | 5.4 | 0.5125 | 0.037037 | 0.069444 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009852 | 0.322581 | 899 | 51 | 58 | 17.627451 | 0.699507 | 0.041157 | 0 | 0.044444 | 1 | 0 | 0.711628 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.022222 | false | 0 | 0.044444 | 0 | 0.2 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7d40cb7ba6dde37868fcb60e13b99c489046be38 | 3,022 | py | Python | twitter_filter/twitter_listener.py | abdulrahimGhazal/twitter_filter | 6fb64fd648734c54b4121f85509190f7dedff12c | [
"MIT"
] | null | null | null | twitter_filter/twitter_listener.py | abdulrahimGhazal/twitter_filter | 6fb64fd648734c54b4121f85509190f7dedff12c | [
"MIT"
] | null | null | null | twitter_filter/twitter_listener.py | abdulrahimGhazal/twitter_filter | 6fb64fd648734c54b4121f85509190f7dedff12c | [
"MIT"
] | null | null | null | # coding=utf-8
"""
This module is the implementation of tweepy.StreamListener.
This includes handling several events like getting a status through
the stream, getting a TweepError, getting an exception, or
connecting/disconnecting to the stream.
"""
import logging
from tweepy import StreamListener
# This class implements tweepy.StreamListener events.
class Listener(StreamListener):
""" This class implements every tweepy.StreamListener event.
This class handles data, error, exception connection and disconnection events.
Attributes:
----------
batcher : Batcher
The batcher instance for batch processing.
"""
def __init__(self, batcher):
"""
Initializer for Listener class.
Parameters
----------
batcher : Batcher
The Batcher object.
"""
self.batcher = batcher
logging.basicConfig(filename='twitter_log.log', format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
super(Listener, self).__init__()
def on_status(self, status):
"""
This function handles status when it is collected from stream.
Parameters
----------
status : tweepy.Status
The collected status object.
Returns
-------
"""
self.batcher.handle_status(status, self.batcher.config)
def on_connect(self):
"""
This function handles when stream is connected.
Parameters
----------
Returns
-------
"""
logging.getLogger("connection").info("connection established.")
def on_disconnect(self, notice):
"""
This function handles when stream disconnects.
Parameters
----------
notice : str
The disconnection notice.
Returns
-------
"""
logging.getLogger("connection").info("connection interrupted: " + notice)
def on_limit(self, track):
"""
This function handles when rate limit is hit.
Parameters
----------
track : int
The total number of undelivered tweets.
Returns
-------
"""
logging.getLogger("limit").info("track limit notice on track: " + str(track))
def on_delete(self, status_id, user_id):
"""
This function handles when tweet is deleted.
Parameters
----------
status_id : int
The deleted tweet id.
user_id : int
The deleted tweet author id.
Returns
-------
"""
logging.getLogger("delete").info("deleted tweet with id: " + str(status_id))
def on_error(self, status_code):
"""
This function handles when error occurs.
Parameters
----------
status_code : int
The error code.
Returns
-------
"""
logging.getLogger("error").info("error: " + str(status_code)) | 21.898551 | 121 | 0.561218 | 297 | 3,022 | 5.62963 | 0.353535 | 0.017943 | 0.068182 | 0.06878 | 0.114833 | 0.05622 | 0 | 0 | 0 | 0 | 0 | 0.000486 | 0.318994 | 3,022 | 138 | 122 | 21.898551 | 0.811953 | 0.474851 | 0 | 0 | 0 | 0 | 0.189215 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.368421 | false | 0 | 0.105263 | 0 | 0.526316 | 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 | 0 | 1 | 0 | 0 | 2 |
7d4cf3a07f0e444d88eb7fb0c900964a426ae5ae | 320 | py | Python | blog/forms.py | Ascensiony/Software-Dev-Project | 85513737ae4a4b76fa0cfdab579b037d33b72faf | [
"MIT"
] | 2 | 2021-03-05T01:38:24.000Z | 2021-03-19T21:11:14.000Z | blog/forms.py | yabhi0807/Software-Dev-Project | 85513737ae4a4b76fa0cfdab579b037d33b72faf | [
"MIT"
] | 7 | 2021-04-08T21:12:42.000Z | 2022-03-12T00:13:59.000Z | blog/forms.py | venky012/ase-1-site | 877e36344c82567d3ebc7b0f29a2757da2a7f071 | [
"MIT"
] | 4 | 2020-02-17T09:47:39.000Z | 2020-02-22T12:11:18.000Z | from django import forms
from .models import Comment, Post
class CommentEditForm(forms.Form):
text = forms.CharField(max_length=50,required=True)
class CommentForm(forms.ModelForm):
body = forms.CharField(max_length=5000,required=True)
class Meta:
model = Comment
fields = ('body',) | 24.615385 | 60 | 0.7 | 39 | 320 | 5.692308 | 0.615385 | 0.126126 | 0.153153 | 0.207207 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023438 | 0.2 | 320 | 13 | 61 | 24.615385 | 0.84375 | 0 | 0 | 0 | 0 | 0 | 0.012945 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.222222 | 0 | 0.777778 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
ada9541f4835ae6a0f9fc9b432f93eaaa59b275e | 433 | py | Python | boardobj/SkillEffect.py | merfolkslivers/gascan-env | abf2affa5cc72f1696a1376e7940fbde262d2389 | [
"MIT"
] | null | null | null | boardobj/SkillEffect.py | merfolkslivers/gascan-env | abf2affa5cc72f1696a1376e7940fbde262d2389 | [
"MIT"
] | null | null | null | boardobj/SkillEffect.py | merfolkslivers/gascan-env | abf2affa5cc72f1696a1376e7940fbde262d2389 | [
"MIT"
] | null | null | null | from abc import ABC, abstractmethod
class SkillEffect(ABC):
def __init__(self, **kwargs):
self.nextTrigger = None # SkillTrigger
if kwargs['trigger']:
self.nextTrigger = kwargs['trigger']
@abstractmethod
def executeeffect(self, **kwargs):
pass
def execute(self, **kwargs):
events = self.executeeffect(kwargs)
self.nextTrigger.checkEligibility(kwargs, events)
| 24.055556 | 57 | 0.646651 | 42 | 433 | 6.571429 | 0.47619 | 0.108696 | 0.152174 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.247113 | 433 | 17 | 58 | 25.470588 | 0.846626 | 0.027714 | 0 | 0 | 0 | 0 | 0.033413 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.083333 | 0.083333 | 0 | 0.416667 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
adbd738a20206755aceb2b4469838fae9a525cfc | 350 | py | Python | flickrTest.py | ciaron/favr3 | 2fd2279b8fbdb77492b4676f12fb8b67b418ab51 | [
"MIT"
] | null | null | null | flickrTest.py | ciaron/favr3 | 2fd2279b8fbdb77492b4676f12fb8b67b418ab51 | [
"MIT"
] | null | null | null | flickrTest.py | ciaron/favr3 | 2fd2279b8fbdb77492b4676f12fb8b67b418ab51 | [
"MIT"
] | null | null | null | from flickrBase import FlickrApiMethod
class FlickrTestLogin(FlickrApiMethod):
name = 'flickr.test.login'
def __init__(self, nojsoncallback=True, format='json', parameters=None):
FlickrApiMethod.__init__(self, nojsoncallback, format, parameters)
def getParameters(self):
p={
#'method' : 'flickr.favorites.getList',
}
return p
| 20.588235 | 73 | 0.74 | 36 | 350 | 6.972222 | 0.694444 | 0.063745 | 0.175299 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.145714 | 350 | 16 | 74 | 21.875 | 0.839465 | 0.111429 | 0 | 0 | 0 | 0 | 0.067742 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.666667 | 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 | 0 | 1 | 0 | 0 | 2 |
adbda3bcb21e9465f19fb2d8ad725e1bb71e656d | 1,445 | py | Python | apiwrapper/api_objects/example_api.py | daxm/apiwrapper | 42a15ce6e2d5f06569937d43ea0a479d9b179de4 | [
"BSD-3-Clause"
] | null | null | null | apiwrapper/api_objects/example_api.py | daxm/apiwrapper | 42a15ce6e2d5f06569937d43ea0a479d9b179de4 | [
"BSD-3-Clause"
] | null | null | null | apiwrapper/api_objects/example_api.py | daxm/apiwrapper | 42a15ce6e2d5f06569937d43ea0a479d9b179de4 | [
"BSD-3-Clause"
] | 1 | 2019-09-06T16:10:43.000Z | 2019-09-06T16:10:43.000Z | from .apiclasstemplate import APIClassTemplate
class Example(APIClassTemplate):
"""
An example API object.
The Example class inherits from the APIClassTemplate all its functions. They can be modified by building a
function with the same name here. For example, the format_data() function inherits from the APIClassTemplate's
format_data() and then is augmented with the code written here.
"""
# What extension to the base URL needs to be appended to call this specific API object.
URL_SUFFIX = '/object/countries'
def __init__(self, server, **kwargs):
super().__init__(server, **kwargs)
logging.debug("In __init__() for Example class.")
self.parse_kwargs(**kwargs)
def format_data(self):
logging.debug("In format_data() for Example class.")
json_data = {}
if 'id' in self.__dict__:
json_data['id'] = self.id
if 'name' in self.__dict__:
json_data['name'] = self.name
return json_data
# If an API method is not supported you can "skip" the APIClassTemplate's version by adding a "pass" here.
def post(self):
logging.info('POST method for API for Example not supported.')
pass
def put(self):
logging.info('POST method for API for Example not supported.')
pass
def delete(self):
logging.info('POST method for API for Example not supported.')
pass
| 35.243902 | 115 | 0.661592 | 194 | 1,445 | 4.773196 | 0.381443 | 0.064795 | 0.048596 | 0.061555 | 0.230022 | 0.191145 | 0.191145 | 0.191145 | 0.191145 | 0.191145 | 0 | 0 | 0.253287 | 1,445 | 40 | 116 | 36.125 | 0.858202 | 0.344637 | 0 | 0.25 | 0 | 0 | 0.254902 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.208333 | false | 0.125 | 0.041667 | 0 | 0.375 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
adc1731523b9b945d161208b826c235c2d160ab2 | 938 | py | Python | jupyter/aBasic/e_file_class/Ex09_reg_method.py | WoolinChoi/test | a0f9c8ecc63443acaae61d744eecec6c943d3a26 | [
"MIT"
] | null | null | null | jupyter/aBasic/e_file_class/Ex09_reg_method.py | WoolinChoi/test | a0f9c8ecc63443acaae61d744eecec6c943d3a26 | [
"MIT"
] | 1 | 2021-03-30T09:01:47.000Z | 2021-03-30T09:01:47.000Z | jupyter/aBasic/e_file_class/Ex09_reg_method.py | WoolinChoi/test | a0f9c8ecc63443acaae61d744eecec6c943d3a26 | [
"MIT"
] | 1 | 2019-12-06T18:21:10.000Z | 2019-12-06T18:21:10.000Z | """
# 패턴과 소스를 비교하는 메소드
- match() : 패턴의 일치여부 확인
- findall() : 일치하는 모든 문자열 리스트 반환
- search() : 첫번째 일치하는 객체 반환
- split() : 패턴에 맞게 소스를 분리한 후 문자열 조각의 리스트 반환
- sub() : 대체 인자로 변환
[참고] 파이썬 정규식 표현 : https://wikidocs.net/4308
"""
import re
# match()
msg = 'We are happy. You are happy. Happy2019 2020'
result = re.match("We", msg)
if result:
print(result.group())
print("-" * 50)
result = re.match("happy", msg)
if result:
print(result.group())
print("-" * 50)
result = re.match(".*happy", msg) # 앞에 문자들이 있을때 .*찾는문자열 해준다.
if result:
print(result.group())
print("-" * 50)
# search()
result = re.search("happy", msg) # 문자열과 일치하는 것을 찾아준다.
if result:
print(result.group())
print("-" * 50)
# split()
result = re.split("a", msg)
if result:
print(result) # 문자열 기준으로 잘라준다.
print("-" * 50)
# sub()
result = re.sub("a", "@", msg)
if result:
print(result) # 문자열을 @로 바꿔준다.
print("-" * 50) | 19.957447 | 63 | 0.573561 | 141 | 938 | 3.815603 | 0.446809 | 0.089219 | 0.144981 | 0.211896 | 0.399628 | 0.399628 | 0.314126 | 0.198885 | 0.198885 | 0.198885 | 0 | 0.033566 | 0.23774 | 938 | 47 | 64 | 19.957447 | 0.718881 | 0.337953 | 0 | 0.692308 | 0 | 0 | 0.122625 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.038462 | 0 | 0.038462 | 0.461538 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
adc6492ff5d4355f4f2a6e9aad3bdb8705fba866 | 225 | py | Python | HW01/demo/mapper.py | maynard242/Machine-Learning-At-Scale | 00406de025e3a94d3514d056a0ec7d46473444ef | [
"MIT"
] | 1 | 2021-10-03T07:52:32.000Z | 2021-10-03T07:52:32.000Z | HW01/demo/mapper.py | maynard242/Machine-Learning-At-Scale | 00406de025e3a94d3514d056a0ec7d46473444ef | [
"MIT"
] | null | null | null | HW01/demo/mapper.py | maynard242/Machine-Learning-At-Scale | 00406de025e3a94d3514d056a0ec7d46473444ef | [
"MIT"
] | 1 | 2020-01-30T02:59:50.000Z | 2020-01-30T02:59:50.000Z | #!/usr/bin/env python
"""
This mapper reads from STDIN and waits 0.001 seconds per line.
Its only purpose is to demonstrate one of the scalability ideas.
"""
import sys
import time
for line in sys.stdin:
time.sleep(0.001) | 25 | 64 | 0.742222 | 40 | 225 | 4.175 | 0.825 | 0.047904 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.042781 | 0.168889 | 225 | 9 | 65 | 25 | 0.850267 | 0.657778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
add993b91b9afdde0b899ff3046a1015cd1c19b6 | 5,525 | py | Python | tool/page_access_trace/symtab.py | systems-nuts/popcorn-compiler-alpine | 5c225c7d3055db83dc654b6b5525c34bbdacded1 | [
"Linux-OpenIB"
] | 30 | 2019-04-07T14:58:31.000Z | 2021-05-24T19:07:20.000Z | tool/page_access_trace/symtab.py | XRDevIEEE/popcorn-compiler | 2cb2eccc0c75b5963d9fec26ad80a7b881316b1d | [
"Linux-OpenIB"
] | 11 | 2018-07-24T19:31:26.000Z | 2020-09-03T08:56:23.000Z | tool/page_access_trace/symtab.py | XRDevIEEE/popcorn-compiler | 2cb2eccc0c75b5963d9fec26ad80a7b881316b1d | [
"Linux-OpenIB"
] | 17 | 2018-08-26T12:43:15.000Z | 2022-03-18T12:08:40.000Z | ''' Symbol table read from the binary. Encapsulates much of the information
described in the ELF specification.
'''
import bisect
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
class Symbol:
''' A symbol read from the binary's symbol table. Translates ELF-specific
information into a query-able API.
'''
''' Symbol types as defined in the ELF specification '''
NoType=0
ObjectType=1 # I.e., static data
FunctionType=0 # I.e., code
SectionType=3
FileType=4
CommonType=5
TLSType=6
@classmethod
def typeNameToInt(cls, name):
''' Convert an ELF symbol type to an integer '''
if name == "STT_OBJECT": return cls.ObjectType
elif name == "STT_FUNC": return cls.FunctionType
elif name == "STT_SECTION": return cls.SectionType
elif name == "STT_FILE": return cls.FileType
elif name == "STT_COMMON": return cls.CommonType
elif name == "STT_TLS": return cls.TLSType
else: return cls.NoType
''' Symbol type getters. '''
def isObject(self): return self.symtype == self.ObjectType
def isFunction(self): return self.symtype == self.FunctionType
def isSection(self): return self.symtype == self.SectionType
def isFile(self): return self.symtype == self.FileType
def isCommon(self): return self.symtype == self.CommonType
def isTLS(self): return self.symtype == self.TLSType
def isData(self):
''' Return whether the symbol is a data object. '''
return self.isObject() or self.isCommon()
def isCode(self):
''' Return whether the symbol is a code object. '''
return self.isFunction()
''' Symbol binding type, i.e., symbol visibility '''
LocalBind=0
GlobalBind=1
WeakBind=2
@classmethod
def bindNameToInt(cls, name):
''' Convert an ELF symbol bind type to an integer '''
if name == "STB_LOCAL": return cls.LocalBind
elif name == "STB_GLOBAL": return cls.GlobalBind
elif name == "STB_WEAK": return cls.WeakBind
else: return -1
''' Binding type getters. '''
def isLocal(self): return self.bindtype == self.LocalBind
def isGlobal(self): return self.bindtype == self.GlobalBind
def isWeak(self): return self.bindtype == self.WeakBind
def contains(self, addr):
''' Return whether the symbol contains a given address. '''
if self.addr <= addr and addr < (self.addr + self.size): return True
else: return False
def __init__(self, name, addr, size, info):
''' Create a symbol using values read from the ELF symbol table. '''
self.name = name
self.addr = addr
self.size = size
self.symtype = Symbol.typeNameToInt(info["type"])
self.bindtype = Symbol.bindNameToInt(info["bind"])
def __lt__(self, other): return self.addr < other.addr
class SymbolTable:
''' A symbol table. Duh. '''
def __init__(self, binary, verbose):
''' Read the symbol table from a file. Return true if we parsed it
correctly, false otherwise.
'''
if verbose: print("-> Parsing symbol table from '{}' <-".format(binary))
with open(binary, 'rb') as binfp:
elf = ELFFile(binfp)
symtabSection = elf.get_section_by_name(".symtab")
assert symtabSection, "No symbol table"
self.symbols = {}
self.addrs = {}
for sym in symtabSection.iter_symbols():
addr = sym["st_value"]
size = sym["st_size"]
if size == 0:
if verbose:
print("Skipping zero-size symbol '{}'".format(sym.name))
continue
# Unfortunately we may have several symbols at the same address
# so we need to maintain a list of symbols per address
newSym = Symbol(sym.name, addr, size, sym["st_info"])
self.symbols[sym.name] = newSym
if addr not in self.addrs: self.addrs[addr] = []
self.addrs[addr].append(newSym)
# Symbols occupy a range of memory rather than a single address,
# making symbol lookups based on a faulting address complicated.
# Create a list of symbols sorted by starting address to facilitate
# a hybrid binary search + range check approach for symbol lookup.
self.sortedaddrs = sorted(self.addrs.keys())
if verbose: print("Parsed {} symbols".format(len(self.symbols)))
def getSymbol(self, addr):
''' Look up the symbol containing the faulting address.
Because symbols occupy a range of memory, we can't simply use a
hash table to map addresses to symbols. Instead, we need an
ordering, so that we can determine the symbol whose starting
address is directly before or equal to the faulting address. Once
we find this symbol (if it exists), we can do a simple range check
to see if the symbol contains the faulting address.
Returns the Symbol object corresponding to the faulting address, or
None if the address doesn't correspond to any symbol.
'''
idx = bisect.bisect_right(self.sortedaddrs, addr)
if idx != 0:
for sym in self.addrs[self.sortedaddrs[idx-1]]:
if sym.contains(addr): return sym
else: return None
| 38.636364 | 80 | 0.61991 | 695 | 5,525 | 4.886331 | 0.315108 | 0.035336 | 0.037102 | 0.037102 | 0.127208 | 0.060071 | 0.017079 | 0 | 0 | 0 | 0 | 0.003553 | 0.286878 | 5,525 | 142 | 81 | 38.908451 | 0.858376 | 0.284706 | 0 | 0.025 | 0 | 0 | 0.061099 | 0 | 0 | 0 | 0 | 0 | 0.0125 | 1 | 0.225 | false | 0 | 0.0375 | 0.125 | 0.4375 | 0.0375 | 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 | 0 | 0 | 0 | 2 |
ade040490fd6f20cffa7656cac6868faed0f5b05 | 154 | py | Python | 2021-04-Python-SEA-ENGRSL-Workshops/Workshop_3-Python-in-Security/code/s05a_s0.py | shawnduong/manimations | 1d36d9d1e7dff90a1a8da1e687ef442f750e29c5 | [
"MIT"
] | null | null | null | 2021-04-Python-SEA-ENGRSL-Workshops/Workshop_3-Python-in-Security/code/s05a_s0.py | shawnduong/manimations | 1d36d9d1e7dff90a1a8da1e687ef442f750e29c5 | [
"MIT"
] | null | null | null | 2021-04-Python-SEA-ENGRSL-Workshops/Workshop_3-Python-in-Security/code/s05a_s0.py | shawnduong/manimations | 1d36d9d1e7dff90a1a8da1e687ef442f750e29c5 | [
"MIT"
] | null | null | null | def functionName(p_1, p_2, p_3, ..., p_n):
Instructions...
return o_1, o_2, o_3, ..., o_m
v_1, v_2, v_3, ..., v_m = functionName(i_1, i_2, i_3, i_n)
| 19.25 | 58 | 0.603896 | 37 | 154 | 2.081081 | 0.351351 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.095238 | 0.181818 | 154 | 7 | 59 | 22 | 0.515873 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ade297575a808ca4ab0fe546b9ccf4bd3ef50b04 | 20,344 | py | Python | tensorflow/core/function/trace_type/default_types.py | huzq85/tensorflow-fork | 92f1dd09bef516a6eb0ad6be6833f28785ef2be8 | [
"Apache-2.0"
] | null | null | null | tensorflow/core/function/trace_type/default_types.py | huzq85/tensorflow-fork | 92f1dd09bef516a6eb0ad6be6833f28785ef2be8 | [
"Apache-2.0"
] | null | null | null | tensorflow/core/function/trace_type/default_types.py | huzq85/tensorflow-fork | 92f1dd09bef516a6eb0ad6be6833f28785ef2be8 | [
"Apache-2.0"
] | null | null | null | # Copyright 2021 The TensorFlow 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.
# ==============================================================================
"""TraceType implementations for common Python types."""
from typing import Any, Hashable, Optional, Sequence, Type
from typing import Dict as PythonDict
from typing import Tuple as PythonTuple
import weakref
from tensorflow.core.function.trace_type import default_types_pb2
from tensorflow.core.function.trace_type import serialization
from tensorflow.python.types import trace
class Literal(trace.TraceType, serialization.Serializable):
"""Represents a Literal type like bool, int or string."""
def __init__(self, value: Any):
self.value = value
self._value_hash = hash(value)
def is_subtype_of(self, other: trace.TraceType) -> bool:
return self == other
def most_specific_common_supertype(
self, types: Sequence[trace.TraceType]) -> Optional["Literal"]:
return self if all(self == other for other in types) else None
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedLiteral]:
return default_types_pb2.SerializedLiteral
@classmethod
def from_proto(cls, proto: default_types_pb2.SerializedLiteral) -> "Literal":
if proto.HasField("bool_value"):
return Literal(proto.bool_value)
if proto.HasField("int_value"):
return Literal(proto.int_value)
if proto.HasField("float_value"):
return Literal(proto.float_value)
if proto.HasField("str_value"):
return Literal(proto.str_value)
raise ValueError("Malformed Literal proto can not be deserialized")
def to_proto(self) -> default_types_pb2.SerializedLiteral:
if isinstance(self.value, bool):
return default_types_pb2.SerializedLiteral(bool_value=self.value)
if isinstance(self.value, int):
return default_types_pb2.SerializedLiteral(int_value=self.value)
if isinstance(self.value, float):
return default_types_pb2.SerializedLiteral(float_value=self.value)
if isinstance(self.value, str):
return default_types_pb2.SerializedLiteral(str_value=self.value)
raise ValueError("Can not serialize Literal of type " +
type(self.value).__name__)
def _placeholder_value(self) -> Any:
return self.value
def __eq__(self, other) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
return isinstance(other, Literal) and self.value == other.value
def __hash__(self) -> int:
return self._value_hash
def __repr__(self):
return f"{self.__class__.__name__}(value={self.value!r})"
class Weakref(trace.TraceType):
"""Represents weakref of an arbitrary Python object.
When a function argument is a custom class, instead of making a copy of it
just for the sake of function cache, a weakref is instead kept to save memory.
"""
def __init__(self, ref: weakref.ReferenceType):
self._ref = ref
self._ref_hash = hash(ref)
def is_subtype_of(self, other: trace.TraceType) -> bool:
return self == other
def most_specific_common_supertype(
self, types: Sequence[trace.TraceType]) -> Optional["Weakref"]:
return self if all(self == other for other in types) else None
def _placeholder_value(self) -> Any:
return self._ref()
def __eq__(self, other):
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, Weakref):
return False
if self._ref() is None or other._ref() is None:
return False
if self._ref() is other._ref():
return True
return self._ref == other._ref
def __hash__(self):
return self._ref_hash
def __repr__(self):
return f"{self.__class__.__name__}(ref={self._ref!r})"
class Tuple(trace.TraceType, serialization.Serializable):
"""Represents a tuple of TraceType objects."""
def __init__(self, *components: trace.TraceType):
self.components = components
def is_subtype_of(self, other: trace.TraceType) -> bool:
if (not isinstance(other, Tuple) or
len(self.components) != len(other.components)):
return False
return all(
self_component.is_subtype_of(other_component) for self_component,
other_component in zip(self.components, other.components))
def most_specific_common_supertype(
self, others: Sequence[trace.TraceType]) -> Optional["Tuple"]:
"""See base class."""
if not all(
isinstance(other, Tuple) and
len(self.components) == len(other.components) for other in others):
return None
supertyped_components = []
for i, component in enumerate(self.components):
supertyped_component = component.most_specific_common_supertype(
[other.components[i] for other in others])
if supertyped_component is None:
return None
supertyped_components.append(supertyped_component)
return Tuple(*supertyped_components)
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedTuple]:
return default_types_pb2.SerializedTuple
@classmethod
def from_proto(cls, proto: default_types_pb2.SerializedTuple) -> "Tuple":
return Tuple(*[serialization.deserialize(c) for c in proto.components])
def to_proto(self) -> default_types_pb2.SerializedTuple:
return default_types_pb2.SerializedTuple(
components=[serialization.serialize(c) for c in self.components])
def _placeholder_value(self) -> Any:
components = [
component._placeholder_value() # pylint: disable=protected-access
for component in self.components
]
return tuple(components)
def __eq__(self, other: Any) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, Tuple):
return False
return self.components == other.components
def __hash__(self) -> int:
return hash(self.components)
def __repr__(self):
return f"Tuple(components={self.components!r})"
class List(trace.TraceType, serialization.Serializable):
"""Represents a list of TraceType objects."""
def __init__(self, *components: trace.TraceType):
self.components_tuple = Tuple(*components)
def is_subtype_of(self, other: trace.TraceType) -> bool:
if not isinstance(other, List):
return False
return self.components_tuple.is_subtype_of(other.components_tuple)
def most_specific_common_supertype(
self, others: Sequence[trace.TraceType]) -> Optional["Tuple"]:
"""See base class."""
if not all(isinstance(other, List) for other in others):
return None
supertyped_components_tuple = self.components_tuple.most_specific_common_supertype(
[other.components_tuple for other in others])
if supertyped_components_tuple is None:
return None
return List(*supertyped_components_tuple.components)
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedList]:
return default_types_pb2.SerializedList
@classmethod
def from_proto(cls, proto: default_types_pb2.SerializedList) -> "List":
return List(*Tuple.from_proto(proto.components_tuple).components)
def to_proto(self) -> default_types_pb2.SerializedList:
return default_types_pb2.SerializedList(
components_tuple=self.components_tuple.to_proto())
def _placeholder_value(self) -> Any:
return list(self.components_tuple._placeholder_value()) # pylint: disable=protected-access
def __eq__(self, other: Any) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, List):
return False
return self.components_tuple == other.components_tuple
def __hash__(self) -> int:
return hash(self.components_tuple)
def __repr__(self):
return f"List(components={self.components_tuple.components!r})"
class NamedTuple(trace.TraceType, serialization.Serializable):
"""Represents a NamedTuple of TraceType objects."""
def __init__(self,
type_name: str,
attribute_names: PythonTuple[str],
attributes: PythonTuple[trace.TraceType],
placeholder_type: Optional[Type[Any]] = None):
self.type_name = type_name
self.attribute_names = attribute_names
self.attributes = Tuple(*attributes)
self._placeholder_type = placeholder_type
@classmethod
def from_type_and_attributes(
cls, named_tuple_type: Any,
attributes: PythonTuple[trace.TraceType]) -> "NamedTuple":
return NamedTuple(named_tuple_type.__name__, named_tuple_type._fields,
attributes, named_tuple_type)
def is_subtype_of(self, other: trace.TraceType) -> bool:
if not isinstance(other, NamedTuple):
return False
return (self.type_name == other.type_name and
self.attribute_names == other.attribute_names and
self.attributes.is_subtype_of(other.attributes))
def most_specific_common_supertype(
self, others: Sequence[trace.TraceType]) -> Optional["NamedTuple"]:
"""See base class."""
if not all(
isinstance(other, NamedTuple) and self.type_name == other.type_name and
self.attribute_names == other.attribute_names for other in others):
return None
supertyped_attributes = self.attributes.most_specific_common_supertype(
[other.attributes for other in others])
if supertyped_attributes is None:
return None
return NamedTuple(self.type_name, self.attribute_names,
supertyped_attributes.components, self._placeholder_type)
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedNamedTuple]:
return default_types_pb2.SerializedNamedTuple
@classmethod
def from_proto(cls,
proto: default_types_pb2.SerializedNamedTuple) -> "NamedTuple":
return NamedTuple(proto.type_name, tuple(proto.attribute_names),
Tuple.from_proto(proto.attributes).components)
def to_proto(self) -> default_types_pb2.SerializedNamedTuple:
return default_types_pb2.SerializedNamedTuple(
type_name=self.type_name,
attribute_names=list(self.attribute_names),
attributes=self.attributes.to_proto())
def _placeholder_value(self) -> Any:
if self._placeholder_type is None:
# We don't need to trace after serialization so it is not needed but we
# can generate a placeholder type using the description if ever needed.
raise ValueError("Can not generate placeholder value for NamedTuple with"
" unspecified placeholder_type. Note: placeholder_type "
"is lost during serialization.")
attribute_placeholders = [
attribute._placeholder_value() # pylint: disable=protected-access
for attribute in self.attributes.components
]
return self._placeholder_type(*attribute_placeholders)
def __hash__(self) -> int:
return hash((self.type_name, self.attribute_names, self.attributes))
def __eq__(self, other: Any) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, NamedTuple):
return False
return (self.type_name == other.type_name and
self.attribute_names == other.attribute_names and
self.attributes == other.attributes)
def __repr__(self):
return (f"NamedTuple(type_name={self.type_name}, "
f"attribute_names={self.attribute_names}, "
f"attributes={self.attributes.components})")
class Attrs(trace.TraceType):
"""Represents a class annotated by attr.s."""
def __init__(self,
type_name: str,
attribute_names: PythonTuple[str],
attributes: PythonTuple[trace.TraceType],
placeholder_type: Optional[Type[Any]] = None):
self.named_attributes = NamedTuple(type_name, attribute_names, attributes)
self._placeholder_type = placeholder_type
@classmethod
def from_type_and_attributes(
cls, attrs_type: Any,
attributes: PythonTuple[trace.TraceType]) -> "Attrs":
return Attrs(attrs_type.__name__,
tuple(attr.name for attr in attrs_type.__attrs_attrs__),
attributes, attrs_type)
def is_subtype_of(self, other: trace.TraceType) -> bool:
if not isinstance(other, Attrs):
return False
return self.named_attributes.is_subtype_of(other.named_attributes)
def most_specific_common_supertype(
self, others: Sequence[trace.TraceType]) -> Optional["Attrs"]:
"""See base class."""
if not all(isinstance(other, Attrs) for other in others):
return None
supertyped_attributes = self.named_attributes.most_specific_common_supertype(
[other.named_attributes for other in others])
if supertyped_attributes is None:
return None
return Attrs(self.named_attributes.type_name,
self.named_attributes.attribute_names,
supertyped_attributes.attributes, self._placeholder_type)
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedAttrs]:
return default_types_pb2.SerializedAttrs
@classmethod
def from_proto(cls, proto: default_types_pb2.SerializedAttrs) -> "Attrs":
return Attrs(proto.named_attributes.type_name,
tuple(proto.named_attributes.attribute_names),
Tuple.from_proto(proto.named_attributes.attributes).components)
def to_proto(self) -> default_types_pb2.SerializedAttrs:
return default_types_pb2.SerializedAttrs(
named_attributes=self.named_attributes.to_proto())
def _placeholder_value(self) -> Any:
if self._placeholder_type is None:
# We don't need to trace after serialization so it is not needed but we
# can generate a placeholder type using the description if ever needed.
raise ValueError("Can not generate placeholder value for Attrs with"
" unspecified placeholder_type. Note: placeholder_type "
"is lost during serialization.")
attribute_placeholders = [
attribute._placeholder_value() # pylint: disable=protected-access
for attribute in self.named_attributes.attributes.components
]
return self._placeholder_type(*attribute_placeholders)
def __hash__(self) -> int:
return hash(self.named_attributes)
def __eq__(self, other: Any) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, Attrs):
return False
return self.named_attributes == other.named_attributes
def __repr__(self):
return (f"Attrs(type_name={self.named_attributes.type_name}, "
f"attribute_names={self.named_attributes.attribute_names}, "
f"attributes={self.named_attributes.attributes.components})")
class Dict(trace.TraceType, serialization.Serializable):
"""Represents a dictionary of TraceType objects.
Attributes:
mapping: A mapping from keys to corresponding TraceTypes of the dict values.
"""
def __init__(self, mapping: PythonDict[Hashable, trace.TraceType]):
self.mapping = mapping
def _has_same_structure(self, other):
if not isinstance(other, Dict):
return False
return self.mapping.keys() == other.mapping.keys()
def is_subtype_of(self, other: trace.TraceType) -> bool:
"""See base class."""
if not self._has_same_structure(other):
return False
# We need all keys to be present because there can be logic relying on
# their existence or lack thereof and hence can not guarantee subtype based
# on a subset or superset of keys.
# Only the tracing code can explicitly check for key dependencies and inform
# that decision.
return all(self.mapping[key].is_subtype_of(other.mapping[key])
for key in self.mapping)
def most_specific_common_supertype(
self, types: Sequence[trace.TraceType]) -> Optional["Dict"]:
"""See base class."""
if not all(self._has_same_structure(other) for other in types):
return None
new_mapping = {}
for key in self.mapping.keys():
common = self.mapping[key].most_specific_common_supertype(
[other.mapping[key] for other in types])
if common is None:
return None
else:
new_mapping[key] = common
return Dict(new_mapping)
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedDict]:
return default_types_pb2.SerializedDict
@classmethod
def from_proto(cls, proto: default_types_pb2.SerializedDict) -> "Dict":
return Dict({
Literal.from_proto(k).value: serialization.deserialize(v)
for k, v in zip(proto.keys, proto.values)
})
def to_proto(self) -> default_types_pb2.SerializedDict:
return default_types_pb2.SerializedDict(
keys=[Literal(k).to_proto() for k in self.mapping.keys()],
values=[serialization.serialize(v) for v in self.mapping.values()])
def _placeholder_value(self) -> Any:
return {
key: value._placeholder_value() # pylint: disable=protected-access
for key, value in self.mapping.items()
}
def __eq__(self, other) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
if not isinstance(other, Dict):
return False
return self.mapping == other.mapping
def __hash__(self) -> int:
return hash(frozenset(self.mapping.keys()))
def __repr__(self):
return f"{self.__class__.__name__}(mapping={self.mapping!r})"
class Reference(trace.TraceType, serialization.Serializable):
"""Represents a resource with an identifier.
Resource identifiers are useful to denote identical resources, that is,
resources which are known at compilation time to point to the same thing.
This information is useful in automatic control dependencies for instance,
where ops using the same resource don't run concurrently.
"""
def __init__(self, base: trace.TraceType, identifier: Hashable):
self.base = base
self.identifier = identifier
def is_subtype_of(self, other: trace.TraceType) -> bool:
if isinstance(other, Reference) and self.identifier == other.identifier:
return self.base.is_subtype_of(other.base)
return False
def most_specific_common_supertype(
self, types: Sequence[trace.TraceType]) -> Optional["Reference"]:
if all(
isinstance(other, Reference) and self.identifier == other.identifier
for other in types):
base_supertype = self.base.most_specific_common_supertype(
[other.base for other in types])
if base_supertype is not None:
return Reference(base_supertype, self.identifier)
return None
@classmethod
def type_proto(cls) -> Type[default_types_pb2.SerializedReference]:
return default_types_pb2.SerializedReference
@classmethod
def from_proto(cls,
proto: default_types_pb2.SerializedReference) -> "Reference":
return Reference(
serialization.deserialize(proto.base),
Literal.from_proto(proto.identifier).value)
def to_proto(self) -> default_types_pb2.SerializedReference:
return default_types_pb2.SerializedReference(
identifier=Literal(self.identifier).to_proto(),
base=serialization.serialize(self.base))
def _placeholder_value(self) -> Any:
return self.base._placeholder_value() # pylint: disable=protected-access
def __eq__(self, other: Any) -> bool:
if not isinstance(other, trace.TraceType):
return NotImplemented
return isinstance(
other, Reference
) and self.identifier == other.identifier and self.base == other.base
def __hash__(self) -> int:
return hash((self.identifier, self.base))
def __repr__(self):
return (f"{self.__class__.__name__}(base={self.base!r}, "
f"identifier={self.identifier!r})")
| 34.657581 | 95 | 0.709595 | 2,499 | 20,344 | 5.546619 | 0.104842 | 0.040401 | 0.042205 | 0.027415 | 0.646274 | 0.577375 | 0.500036 | 0.463459 | 0.427314 | 0.328043 | 0 | 0.002868 | 0.194554 | 20,344 | 586 | 96 | 34.716724 | 0.843037 | 0.11974 | 0 | 0.394402 | 0 | 0 | 0.061477 | 0.033073 | 0 | 0 | 0 | 0 | 0 | 1 | 0.203562 | false | 0 | 0.017812 | 0.117048 | 0.526718 | 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 | 0 | 0 | 0 | 2 |
adef7c269e8dee7e0f7b6ed34e5c45bb438aef06 | 413 | py | Python | pytpp/attributes/capi_trust_store.py | Venafi/pytpp | 42af655b2403b8c9447c86962abd4aaa0201f646 | [
"MIT"
] | 4 | 2022-02-04T23:58:55.000Z | 2022-02-15T18:53:08.000Z | pytpp/attributes/capi_trust_store.py | Venafi/pytpp | 42af655b2403b8c9447c86962abd4aaa0201f646 | [
"MIT"
] | null | null | null | pytpp/attributes/capi_trust_store.py | Venafi/pytpp | 42af655b2403b8c9447c86962abd4aaa0201f646 | [
"MIT"
] | null | null | null | from pytpp.attributes._helper import IterableMeta, Attribute
from pytpp.attributes.certificate_trust_store_base import CertificateTrustStoreBaseAttributes
class CAPITrustStoreAttributes(CertificateTrustStoreBaseAttributes, metaclass=IterableMeta):
__config_class__ = "CAPI Trust Store"
log_windows_events = Attribute('Log Windows Events')
trust_store_name = Attribute('Trust Store Name', min_version='20.1')
| 45.888889 | 93 | 0.8523 | 44 | 413 | 7.681818 | 0.568182 | 0.118343 | 0.112426 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007895 | 0.079903 | 413 | 8 | 94 | 51.625 | 0.881579 | 0 | 0 | 0 | 0 | 0 | 0.130751 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 2 |
adf404f9175a8fe2cbcdd2b0272ea08c44a9ab89 | 1,498 | py | Python | covid19vaccini/Covid19Vaccini.py | reale/covid19vaccini | 4b0158705fa7c71349ef63417a63ab32d521e175 | [
"MIT"
] | 1 | 2021-02-01T11:34:23.000Z | 2021-02-01T11:34:23.000Z | covid19vaccini/Covid19Vaccini.py | reale/covid19vaccini | 4b0158705fa7c71349ef63417a63ab32d521e175 | [
"MIT"
] | null | null | null | covid19vaccini/Covid19Vaccini.py | reale/covid19vaccini | 4b0158705fa7c71349ef63417a63ab32d521e175 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# Covid19Vaccini
#
# Consumes open data about Covid-19 in Italy
import urllib.request, urllib.parse, json
import pandas as pd
BASE_URL = 'https://github.com/italia/covid19-opendata-vaccini/blob/master/dati/'
class Covid19Vaccini(object):
def __build_url(self, url):
url = urllib.parse.urljoin(BASE_URL, url)
return '{}?{}'.format(url, 'raw=true')
def __getter(self, url):
with urllib.request.urlopen(self.__build_url(url)) as u:
data = json.loads(u.read().decode())
df = pd.DataFrame(pd.json_normalize(data, 'data'))
return df
@property
def anagrafica_vaccini_summary_latest(self):
return self.__getter('anagrafica-vaccini-summary-latest.json')
@property
def consegne_vaccini_latest(self):
return self.__getter('consegne-vaccini-latest.json')
@property
def last_update_dataset(self):
return self.__getter('last-update-dataset.json')
@property
def punti_somministrazione_latest(self):
return self.__getter('punti-somministrazione-latest.json')
@property
def somministrazioni_vaccini_latest(self):
return self.__getter('somministrazioni-vaccini-latest.json')
@property
def somministrazioni_vaccini_summary_latest(self):
return self.__getter('somministrazioni-vaccini-summary-latest.json')
@property
def vaccini_summary_latest(self):
return self.__getter('vaccini-summary-latest.json')
| 29.372549 | 81 | 0.697597 | 180 | 1,498 | 5.577778 | 0.355556 | 0.076693 | 0.09761 | 0.139442 | 0.421315 | 0.36753 | 0.191235 | 0 | 0 | 0 | 0 | 0.006568 | 0.186916 | 1,498 | 50 | 82 | 29.96 | 0.817734 | 0.052069 | 0 | 0.212121 | 0 | 0 | 0.223164 | 0.163136 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.060606 | 0.212121 | 0.636364 | 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 | 0 | 0 | 0 | 2 |
adf4865a0a2923c280dbc5a11b8d32958670d739 | 779 | py | Python | server/src/api/usecases/user.py | Mokumoku-Rin/client | 7352c651edff79a28a0056d60d483a1753a7354d | [
"Apache-2.0"
] | null | null | null | server/src/api/usecases/user.py | Mokumoku-Rin/client | 7352c651edff79a28a0056d60d483a1753a7354d | [
"Apache-2.0"
] | 109 | 2020-03-02T08:44:44.000Z | 2022-02-27T00:32:30.000Z | server/src/api/usecases/user.py | Mokumoku-Rin/client | 7352c651edff79a28a0056d60d483a1753a7354d | [
"Apache-2.0"
] | 1 | 2020-03-19T06:13:33.000Z | 2020-03-19T06:13:33.000Z | from db.user import (get_user, get_user_score,
get_users_name_img_by_score_and_course_done, insert_user)
def is_existed_user(uid):
user = get_user(uid)
if user:
return True
return False
def add_user(uid, name, img_url):
insert_user(uid, name, img_url)
def get_user_list_by_score_close(user_score: str, course_id: str) -> list:
"""
ユーザスコアが近く,かつ指定のコースIDを走ったユーザの情報リストをゴースト用に整形して返す
Parameters
----------
user_score : 対象ユーザのスコア
course_id : 対象コースID
Returns
-------
user_list : list
[
{id: str, name: str, img_url: str
]
"""
user_list = get_users_name_img_by_score_and_course_done(
user_score, course_id, 7)
return user_list
| 22.257143 | 78 | 0.621309 | 101 | 779 | 4.376238 | 0.346535 | 0.063348 | 0.049774 | 0.067873 | 0.235294 | 0.158371 | 0.158371 | 0.158371 | 0.158371 | 0 | 0 | 0.001805 | 0.288832 | 779 | 34 | 79 | 22.911765 | 0.796029 | 0.287548 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.076923 | 0 | 0.538462 | 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 | 0 | 1 | 0 | 0 | 2 |
bc00c08f97917ad1a41181c83f9245ce800c3102 | 238 | py | Python | INF1511/Chapter2/Arithmetic/octhex.py | GalliWare/UNISA-studies | 32bab94930b176c4dfe943439781ef102896fab5 | [
"Unlicense"
] | null | null | null | INF1511/Chapter2/Arithmetic/octhex.py | GalliWare/UNISA-studies | 32bab94930b176c4dfe943439781ef102896fab5 | [
"Unlicense"
] | null | null | null | INF1511/Chapter2/Arithmetic/octhex.py | GalliWare/UNISA-studies | 32bab94930b176c4dfe943439781ef102896fab5 | [
"Unlicense"
] | null | null | null | # example of how to display octal and hexa values
a = 0o25
b = 0x1af
print('Value of a in decimal is ', a)
c = 19
print('19 in octal is %o and in hex is %x' % (c, c))
d = oct(c)
e = hex(c)
print('19 in octal is', d, ' and in hex is ', e)
| 23.8 | 52 | 0.613445 | 53 | 238 | 2.754717 | 0.490566 | 0.09589 | 0.123288 | 0.191781 | 0.219178 | 0 | 0 | 0 | 0 | 0 | 0 | 0.061111 | 0.243697 | 238 | 9 | 53 | 26.444444 | 0.75 | 0.197479 | 0 | 0 | 0 | 0 | 0.465608 | 0 | 0 | 0 | 0.026455 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.375 | 0 | 0 | 0 | null | 0 | 0 | 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 | 2 |
70ab0a1afd22c374956e4726234cf6b35e8b124e | 190 | py | Python | tg_bot/handlers/__init__.py | EeOneDown/spbu4u | 2ad01088fb167c80c53b757a0247fc5cde34c20f | [
"Apache-2.0"
] | 30 | 2017-09-14T20:25:43.000Z | 2022-03-12T09:55:35.000Z | tg_bot/handlers/__init__.py | EeOneDown/spbu4u | 2ad01088fb167c80c53b757a0247fc5cde34c20f | [
"Apache-2.0"
] | 59 | 2018-01-12T18:29:24.000Z | 2019-03-08T21:08:40.000Z | tg_bot/handlers/__init__.py | EeOneDown/spbu4u | 2ad01088fb167c80c53b757a0247fc5cde34c20f | [
"Apache-2.0"
] | 8 | 2017-12-01T18:36:04.000Z | 2020-11-22T00:36:15.000Z | from tg_bot.handlers import (
start,
registration,
info,
main_menu,
schedule,
attestation,
suburbans,
editor,
rate,
other_text,
inline_handlers
)
| 13.571429 | 29 | 0.615789 | 19 | 190 | 5.947368 | 0.947368 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.315789 | 190 | 13 | 30 | 14.615385 | 0.869231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.076923 | 0 | 0.076923 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
70ac4f5b468110bfb2a7b0ef38994b2f942785de | 2,680 | py | Python | maze/models.py | Lapin-Blanc/maze_project | 00111d9af9b9d2453e8906d73ee788042a4d4ddd | [
"MIT"
] | null | null | null | maze/models.py | Lapin-Blanc/maze_project | 00111d9af9b9d2453e8906d73ee788042a4d4ddd | [
"MIT"
] | 8 | 2020-10-28T07:25:11.000Z | 2021-09-22T19:31:52.000Z | maze/models.py | Lapin-Blanc/maze_project | 00111d9af9b9d2453e8906d73ee788042a4d4ddd | [
"MIT"
] | null | null | null | # maze.models
from django.db import models
from django.urls import reverse
# Create your models here.
class Block(models.Model):
name = models.CharField('nom', max_length=50)
def __str__(self):
return self.name
class Pixel(models.Model):
name = models.CharField('nom', max_length=20)
sprite = models.ImageField('fichier sprites', upload_to='sprites/')
downIndex = models.IntegerField('index direction bas', default=8)
clockWise = models.BooleanField('rotation horaire', default = True)
nbHPix = models.IntegerField('sprites horizontaux', default = 16)
nbVPix = models.IntegerField('sprites verticaux', default = 1)
icon = models.ImageField('icône', null=True)
class Meta:
ordering = ['name']
def __str__(self):
return self.name
class Character(models.Model):
name = models.CharField('nom', max_length=20)
posX = models.IntegerField('position horizontale', default=0)
posY = models.IntegerField('position verticale', default=0)
direction = models.CharField('direction', max_length = 5,
choices = (('up','haut'),('right','droite'),('down','bas'),('left','gauche')),
default='down')
pixel = models.ForeignKey(Pixel, verbose_name='pixels', on_delete=models.CASCADE, null=True)
niveau = models.ForeignKey('Level', on_delete=models.CASCADE)
def get_absolute_url(self):
return reverse('maze:char_preview', kwargs={'char_id': self.id})
class Meta:
ordering = ['name']
def __str__(self):
return self.name
class Level(models.Model):
name = models.CharField('nom', max_length=50)
lvl_map = models.TextField('carte', default=
'''[
["I","H","H","H","H","H","H","H","H","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","_","_","_","_","_","_","_","_","I"],
["I","I","I","I","I","I","I","I","I","I"]]'''
)
maxBlocks = models.IntegerField('nombre max de blocs', default=0)
blocks = models.ManyToManyField(Block, verbose_name='blocs disponibles')
description = models.TextField('Description', default='')
class Meta:
verbose_name_plural = 'niveaux'
ordering = ['name']
def get_absolute_url(self):
return reverse('maze:edit', kwargs={'level_id': self.id})
def __str__(self):
return self.name
| 35.263158 | 96 | 0.572388 | 289 | 2,680 | 4.961938 | 0.356401 | 0.036262 | 0.052301 | 0.066946 | 0.306834 | 0.306834 | 0.290098 | 0.264296 | 0.211297 | 0.088563 | 0 | 0.007428 | 0.196269 | 2,680 | 75 | 97 | 35.733333 | 0.65831 | 0.013433 | 0 | 0.425532 | 0 | 0 | 0.150188 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.12766 | false | 0 | 0.042553 | 0.12766 | 0.851064 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
70b6cf7cd195348264a88860d87973c8ba438e00 | 1,405 | py | Python | app/stops/migrations/0001_initial.py | IvanBodnar/subway-api | 36d17533995394fc5a5e6e1707ef312778296869 | [
"MIT"
] | null | null | null | app/stops/migrations/0001_initial.py | IvanBodnar/subway-api | 36d17533995394fc5a5e6e1707ef312778296869 | [
"MIT"
] | 9 | 2019-12-04T23:23:07.000Z | 2022-02-10T08:12:30.000Z | app/stops/migrations/0001_initial.py | IvanBodnar/subway-api | 36d17533995394fc5a5e6e1707ef312778296869 | [
"MIT"
] | null | null | null | # Generated by Django 2.2.2 on 2019-06-22 18:23
import django.contrib.gis.db.models.fields
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Stops',
fields=[
('id', models.IntegerField(primary_key=True, serialize=False)),
('tipo', models.CharField(max_length=255, null=True)),
('calle', models.CharField(max_length=255, null=True)),
('numero', models.IntegerField(null=True)),
('entre1', models.CharField(max_length=255, null=True)),
('entre2', models.CharField(max_length=255, null=True)),
('lineas', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), size=None)),
('dir_norm', models.CharField(max_length=255, null=True)),
('metrobus', models.BooleanField()),
('stop_desc', models.CharField(max_length=255, null=True)),
('x', models.FloatField()),
('y', models.FloatField()),
('geom', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('geom_98334', django.contrib.gis.db.models.fields.PointField(srid=98334)),
],
),
]
| 39.027778 | 115 | 0.586477 | 148 | 1,405 | 5.493243 | 0.432432 | 0.068881 | 0.132841 | 0.177122 | 0.403444 | 0.403444 | 0.366544 | 0.108241 | 0 | 0 | 0 | 0.047481 | 0.26548 | 1,405 | 35 | 116 | 40.142857 | 0.74031 | 0.032028 | 0 | 0 | 1 | 0 | 0.059647 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.107143 | 0 | 0.25 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
70ca0d38aa043c357a12f9551bd3517fecdfb8ac | 1,380 | py | Python | thermodynamics.py | BApplB/rocket-nozzle-tools | 94f35cefe658a6131cd2f30aad34d031c21de542 | [
"MIT"
] | 1 | 2020-07-08T23:51:50.000Z | 2020-07-08T23:51:50.000Z | thermodynamics.py | BApplB/rocket-nozzle-tools | 94f35cefe658a6131cd2f30aad34d031c21de542 | [
"MIT"
] | null | null | null | thermodynamics.py | BApplB/rocket-nozzle-tools | 94f35cefe658a6131cd2f30aad34d031c21de542 | [
"MIT"
] | null | null | null | #rocket-nozzle-tools
__author__ = "Ben Appleby"
__email__ = "ben.appleby@sky.com","b6040585@my.shu.ac.uk"
__copyright__ = "Copyright 2019, Ben Appleby"
import math
"""Common thermodynamics functions"""
def x_function(mach,gamma):
gp1 = gamma+1
gm1 = gamma-1
return mach*math.sqrt(gamma)*(1+(gm1/2)*mach**2)**(-gp1/(2*gm1))
def pratio(mach,gamma):
pressure_ratio = (1+((gamma-1)/2)*mach**2)**(gamma/(gamma-1))
return pressure_ratio
def aratio(mach,gamma):
area_ratio = ((gamma+1)/2)**(-((gamma+1)/(gamma-1)/2)) / mach * (1 + mach**2 * (gamma-1)/2)**((gamma+1)/(gamma-1)/2)
return area_ratio
def rhoratio(mach,gamma):
rho_ratio = (1+((gamma-1)/2)*mach**2)**(-1/(gamma-1))
return rho_ratio
def tratio(mach,gamma):
temperature_ratio = (1+((gamma-1)/2)*mach**2)**(-1)
return temperature_ratio
def pcrit(gamma):
pressure_critical = (2/(gamma+1))**(gamma/(gamma-1))
return pressure_critical
def calc_oxidizer_temp(chamberPressure,chamberTemp,OxTemp):
return (chamberPressure*OxTemp)/chamberTemp
def calc_prandtl_meyer_angle(mach,gamma):
calc_pm = math.sqrt(gamma+1/gamma-1)*math.atan(math.sqrt((gamma-1/gamma+1)*(mach**2-1)))-math.atan(math.sqrt(mach**2-1))
return calc_pm
def sound_speed(gamma,specificgasconstant,temperature):
calc_sos = math.sqrt(gamma*specificgasconstant*temperature)
return calc_sos | 31.363636 | 124 | 0.686957 | 208 | 1,380 | 4.399038 | 0.278846 | 0.131148 | 0.061202 | 0.043716 | 0.234973 | 0.148634 | 0.104918 | 0.085246 | 0 | 0 | 0 | 0.050497 | 0.124638 | 1,380 | 44 | 125 | 31.363636 | 0.706954 | 0.013768 | 0 | 0 | 0 | 0 | 0.058912 | 0.015861 | 0 | 0 | 0 | 0 | 0 | 1 | 0.290323 | false | 0 | 0.032258 | 0.032258 | 0.612903 | 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 | 0 | 1 | 0 | 0 | 2 |
70ca9d5b222a279ab9a75679628e89575437eb31 | 494 | py | Python | files/migrations/0005_auto_20200406_1634.py | Asko-Dev/File_Upload_RESTAPI | 4effc6fa515668a1e6367b0e61ebcf7e21576884 | [
"MIT"
] | null | null | null | files/migrations/0005_auto_20200406_1634.py | Asko-Dev/File_Upload_RESTAPI | 4effc6fa515668a1e6367b0e61ebcf7e21576884 | [
"MIT"
] | 7 | 2021-03-19T01:43:12.000Z | 2022-03-12T00:22:42.000Z | files/migrations/0005_auto_20200406_1634.py | Asko-Dev/File_Upload_RESTAPI | 4effc6fa515668a1e6367b0e61ebcf7e21576884 | [
"MIT"
] | null | null | null | # Generated by Django 3.0.4 on 2020-04-06 16:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('files', '0004_auto_20200406_1631'),
]
operations = [
migrations.RemoveField(
model_name='fileupload',
name='tag',
),
migrations.AddField(
model_name='fileupload',
name='tag',
field=models.ManyToManyField(to='files.Tag'),
),
]
| 21.478261 | 57 | 0.566802 | 49 | 494 | 5.612245 | 0.714286 | 0.065455 | 0.138182 | 0.167273 | 0.189091 | 0 | 0 | 0 | 0 | 0 | 0 | 0.091445 | 0.313765 | 494 | 22 | 58 | 22.454545 | 0.719764 | 0.091093 | 0 | 0.375 | 1 | 0 | 0.14094 | 0.051454 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.0625 | 0 | 0.25 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
70e3040a85bc9e121f7a5949e609a403a5f9d976 | 700 | py | Python | formula/portaudio.py | mfichman/winbrew | 26496261753d849d5da2f7d465a62297aef46ac9 | [
"MIT"
] | 19 | 2015-03-18T01:11:20.000Z | 2021-08-01T18:51:54.000Z | formula/portaudio.py | mfichman/winbrew | 26496261753d849d5da2f7d465a62297aef46ac9 | [
"MIT"
] | 11 | 2015-12-17T02:13:10.000Z | 2017-07-21T14:15:13.000Z | formula/portaudio.py | mfichman/winbrew | 26496261753d849d5da2f7d465a62297aef46ac9 | [
"MIT"
] | 6 | 2015-05-14T19:50:15.000Z | 2020-11-22T08:55:03.000Z |
import winbrew
class Portaudio(winbrew.Formula):
url = 'http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz'
homepage = 'https://portaudio.com'
sha1 = 'b7e9b9c53d993f6d110487ef56a3d4529d21b2f1'
build_deps = ('cmake',)
deps = ()
def build(self):
self.cmake_build('bld')
def install(self):
self.lib(r'bld\Release\portaudio_x64.dll', 'portaudio_x64.dll')
self.lib(r'bld\Release\portaudio_x64.lib', 'portaudio.lib')
self.lib(r'bld\Release\portaudio_x64.exp', 'portaudio.exp')
self.lib(r'bld\Release\portaudio_static_x64.lib', 'portaudio-static.lib')
self.includes('include')
def test(self):
pass
| 30.434783 | 81 | 0.67 | 87 | 700 | 5.264368 | 0.425287 | 0.061135 | 0.069869 | 0.09607 | 0.255459 | 0.255459 | 0.196507 | 0 | 0 | 0 | 0 | 0.089317 | 0.184286 | 700 | 22 | 82 | 31.818182 | 0.712785 | 0 | 0 | 0 | 0 | 0 | 0.469242 | 0.23319 | 0 | 0 | 0 | 0 | 0 | 1 | 0.176471 | false | 0.058824 | 0.058824 | 0 | 0.588235 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
70e8d7f3f55df6253fa496ff97f0c1d2e2e32bce | 217 | py | Python | src/tsadmapi/urls.py | tsadm/webapp | 85056841fbaa06de18844630977b163a6a999e8a | [
"BSD-3-Clause"
] | null | null | null | src/tsadmapi/urls.py | tsadm/webapp | 85056841fbaa06de18844630977b163a6a999e8a | [
"BSD-3-Clause"
] | null | null | null | src/tsadmapi/urls.py | tsadm/webapp | 85056841fbaa06de18844630977b163a6a999e8a | [
"BSD-3-Clause"
] | null | null | null | from django.conf.urls import url, include
urlpatterns = [
url(r'^inventory/', include('tsadmapi.inventory.urls', namespace='inventory')),
url(r'^slave/', include('tsadmapi.slave.urls', namespace='slave')),
]
| 31 | 83 | 0.695853 | 26 | 217 | 5.807692 | 0.5 | 0.05298 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.110599 | 217 | 6 | 84 | 36.166667 | 0.782383 | 0 | 0 | 0 | 0 | 0 | 0.341014 | 0.105991 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 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 | 0 | 0 | 0 | 2 |
cb0b25450f59185ff251a6f6a74d115f93757d51 | 1,872 | py | Python | imix/engine/hooks/base_hook.py | linxi1158/iMIX | af87a17275f02c94932bb2e29f132a84db812002 | [
"Apache-2.0"
] | 23 | 2021-06-26T08:45:19.000Z | 2022-03-02T02:13:33.000Z | imix/engine/hooks/base_hook.py | XChuanLee/iMIX | 99898de97ef8b45462ca1d6bf2542e423a73d769 | [
"Apache-2.0"
] | null | null | null | imix/engine/hooks/base_hook.py | XChuanLee/iMIX | 99898de97ef8b45462ca1d6bf2542e423a73d769 | [
"Apache-2.0"
] | 9 | 2021-06-10T02:36:20.000Z | 2021-11-09T02:18:16.000Z | import enum
from typing import Union
@enum.unique
class PriorityStatus(enum.Enum):
HIGHEST = 0
HIGHER = 10
HIGH = 20
NORMAL = 30
LOW = 40
LOWER = 50
LOWEST = 60
class HookBase:
"""HookBase is the base class of all hook and is registered in EngineBase class.
The subclasses of HookBase implement the following six methods according to needed.
::
hook.before_train()
for iter in range(start_iter,max_iter):
hook.before_train_iter()
train.run_train_iter()
hook.after_train_iter()
hook.after_epoch()
hook.after_train()
"""
def __init__(self):
self._level = PriorityStatus.NORMAL
def before_train(self):
pass
def after_train(self):
pass
def before_train_iter(self):
pass
def after_train_iter(self):
pass
def before_train_epoch(self):
pass
def after_train_epoch(self):
pass
@property
def level(self):
return self._level
@level.setter
def level(self, level: Union[PriorityStatus, str, int]):
assert isinstance(level, (PriorityStatus, str, int))
if isinstance(level, PriorityStatus):
self._level = level
else:
level_name = list(PriorityStatus.__members__.keys())
level_value = list(lv.value for lv in PriorityStatus.__members__.values())
if level in level_name or level in level_value:
self._level = PriorityStatus[level.upper()] if isinstance(level_name, str) else PriorityStatus(level)
else:
import logging
logger = logging.getLogger(__name__)
logger.warning(f'because level{level} is not a PriorityStatus type,it will be set as default type')
self._level = PriorityStatus.NORMAL
| 26.742857 | 117 | 0.622329 | 224 | 1,872 | 4.991071 | 0.397321 | 0.048301 | 0.049195 | 0.042934 | 0.102862 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009931 | 0.300748 | 1,872 | 69 | 118 | 27.130435 | 0.844156 | 0.199786 | 0 | 0.227273 | 0 | 0 | 0.055134 | 0 | 0 | 0 | 0 | 0 | 0.022727 | 1 | 0.204545 | false | 0.136364 | 0.068182 | 0.022727 | 0.5 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
cb0d921c1f1810c2236e77561bf3ae02c1b2eeba | 300 | py | Python | w3resource/Basics-Part II/Example001.py | DanielPascualSenties/pythonw3 | f0355d1b640dec19e0b087797538204332111bb5 | [
"MIT"
] | null | null | null | w3resource/Basics-Part II/Example001.py | DanielPascualSenties/pythonw3 | f0355d1b640dec19e0b087797538204332111bb5 | [
"MIT"
] | null | null | null | w3resource/Basics-Part II/Example001.py | DanielPascualSenties/pythonw3 | f0355d1b640dec19e0b087797538204332111bb5 | [
"MIT"
] | null | null | null | lis = [1, 2, 3, 4, 2, 6, 7, 8, 9]
without_duplicates = []
ok = True
for i in range(0,len(lis)):
if lis[i] in without_duplicates:
ok = False
break
else:
without_duplicates.append(lis[i])
if ok:
print("There are no duplicates")
else:
print("Things are not ok") | 20 | 41 | 0.586667 | 49 | 300 | 3.530612 | 0.612245 | 0.294798 | 0.219653 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.046083 | 0.276667 | 300 | 15 | 42 | 20 | 0.751152 | 0 | 0 | 0.153846 | 0 | 0 | 0.13289 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.153846 | 0 | 0 | 0 | null | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cb171db8d3e23188e9624267089785cecd8e7698 | 276 | py | Python | modelutils/caffe/load.py | shonohs/modelutils | 24df495ce5372c3f8a1f064f163b51150517e2de | [
"MIT"
] | 1 | 2020-12-10T07:06:32.000Z | 2020-12-10T07:06:32.000Z | modelutils/caffe/load.py | shonohs/modelutils | 24df495ce5372c3f8a1f064f163b51150517e2de | [
"MIT"
] | null | null | null | modelutils/caffe/load.py | shonohs/modelutils | 24df495ce5372c3f8a1f064f163b51150517e2de | [
"MIT"
] | null | null | null | from google.protobuf import text_format
def load_model(input_filepath, output_filepath):
from caffe.proto import caffe_pb2
net = caffe_pb2.NetParameter()
text_format.Parse(input_filepath.read_text(), net)
output_filepath.write_bytes(net.SerializeToString())
| 30.666667 | 56 | 0.789855 | 37 | 276 | 5.594595 | 0.594595 | 0.096618 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008299 | 0.126812 | 276 | 8 | 57 | 34.5 | 0.850622 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
cb1fc49b8fa223be23b6675278f371f4d1b55ecd | 259 | py | Python | dataent/templates/autodoc/contents.py | dataent/dataent | c41bd5942ffe5513f4d921c4c0595c84bbc422b4 | [
"MIT"
] | null | null | null | dataent/templates/autodoc/contents.py | dataent/dataent | c41bd5942ffe5513f4d921c4c0595c84bbc422b4 | [
"MIT"
] | 6 | 2020-03-24T17:15:56.000Z | 2022-02-10T18:41:31.000Z | dataent/templates/autodoc/contents.py | dataent/dataent | c41bd5942ffe5513f4d921c4c0595c84bbc422b4 | [
"MIT"
] | null | null | null | # Copyright (c) 2015, Dataent Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import dataent
from dataent.website.utils import get_full_index
def get_context(context):
context.full_index = get_full_index()
| 25.9 | 69 | 0.814672 | 37 | 259 | 5.405405 | 0.648649 | 0.135 | 0.12 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017544 | 0.119691 | 259 | 9 | 70 | 28.777778 | 0.859649 | 0.320463 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.6 | 0 | 0.8 | 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 | 1 | 0 | 0 | 0 | 0 | 2 |
cb2eb4e61f771da2ea03a4892417afa6856614cd | 143 | py | Python | tests/conftest.py | hemma/py-lambda-simulator | 602aff47900116802149821b52157fd0eaa80d08 | [
"MIT"
] | 1 | 2022-02-09T21:48:16.000Z | 2022-02-09T21:48:16.000Z | tests/conftest.py | hemma/py-lambda-simulator | 602aff47900116802149821b52157fd0eaa80d08 | [
"MIT"
] | null | null | null | tests/conftest.py | hemma/py-lambda-simulator | 602aff47900116802149821b52157fd0eaa80d08 | [
"MIT"
] | null | null | null | import asyncio
import pytest
@pytest.fixture(scope="module")
def loop():
loop = asyncio.get_event_loop()
yield loop
loop.close()
| 14.3 | 35 | 0.692308 | 19 | 143 | 5.105263 | 0.631579 | 0.164948 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.188811 | 143 | 9 | 36 | 15.888889 | 0.836207 | 0 | 0 | 0 | 0 | 0 | 0.041958 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cb3344245b5b31fdfb81ce963722d84b14208888 | 355 | py | Python | src/tenyksscripts/scripts/aww.py | ericbutera/tenyks-contrib | c1152656f3fe7135b5c3331a9fc215666c6df532 | [
"MIT"
] | 7 | 2015-10-26T06:31:07.000Z | 2018-07-10T17:38:11.000Z | src/tenyksscripts/scripts/aww.py | ericbutera/tenyks-contrib | c1152656f3fe7135b5c3331a9fc215666c6df532 | [
"MIT"
] | 22 | 2015-04-16T06:29:25.000Z | 2022-03-19T18:41:33.000Z | src/tenyksscripts/scripts/aww.py | ericbutera/tenyks-contrib | c1152656f3fe7135b5c3331a9fc215666c6df532 | [
"MIT"
] | 5 | 2015-10-23T21:31:21.000Z | 2018-07-10T17:30:10.000Z | import re
import random
import requests
def run(data, settings):
if re.compile(r'(?i)i( am|\'m) (sad|bummed)').match(
data['payload']):
aww_r = requests.get('http://www.reddit.com/r/aww.json')
aww_json = random.choice(aww_r.json()['data']['children'])
return 'daaawwwww {url}'.format(url=aww_json['data']['url'])
| 29.583333 | 68 | 0.611268 | 52 | 355 | 4.096154 | 0.596154 | 0.098592 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.183099 | 355 | 11 | 69 | 32.272727 | 0.734483 | 0 | 0 | 0 | 0 | 0 | 0.23662 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
cb37d1e2fcaf7df0d2df8f94342a8d51a683f714 | 463 | py | Python | bdo/download.py | sihrc/bdo-image2text | 17c346b440ad647da56c38c23ba5783a412d8259 | [
"MIT"
] | 1 | 2019-04-18T19:16:16.000Z | 2019-04-18T19:16:16.000Z | bdo/download.py | sihrc/bdo-image2text | 17c346b440ad647da56c38c23ba5783a412d8259 | [
"MIT"
] | null | null | null | bdo/download.py | sihrc/bdo-image2text | 17c346b440ad647da56c38c23ba5783a412d8259 | [
"MIT"
] | null | null | null | import requests
import socket
from urllib.parse import unquote_plus as urllib_unquote_plus
from urllib.error import HTTPError, URLError
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
}
def get_content_from_url(url):
url = urllib_unquote_plus(url).strip()
headers = dict(HEADERS)
return requests.get(url, headers=headers, timeout=5).content
| 27.235294 | 140 | 0.75378 | 72 | 463 | 4.708333 | 0.611111 | 0.097345 | 0.100295 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.06801 | 0.142549 | 463 | 16 | 141 | 28.9375 | 0.785894 | 0 | 0 | 0 | 0 | 0.090909 | 0.280778 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.545455 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
cb52447aea68112909b65e9aeb941d96041e4d18 | 575 | py | Python | pastebin/users/viewsets.py | amirasaad/pastebin | dba0617337a61646cba3bed7f35f4afa1618a49e | [
"MIT"
] | null | null | null | pastebin/users/viewsets.py | amirasaad/pastebin | dba0617337a61646cba3bed7f35f4afa1618a49e | [
"MIT"
] | 192 | 2020-01-07T12:10:04.000Z | 2022-03-27T17:32:32.000Z | pastebin/users/viewsets.py | amirasaad/pastebin | dba0617337a61646cba3bed7f35f4afa1618a49e | [
"MIT"
] | null | null | null | from django.contrib.auth import get_user_model
from rest_framework import filters
from rest_framework.viewsets import ModelViewSet
from pastebin.users.permissions import IsAuthenticatedOrCreate
from pastebin.users.serializers import UserSerializer
User = get_user_model()
class UsersViewSet(ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
filter_backends = [filters.SearchFilter]
search_fields = ["username", "email"]
http_method_names = ["get", "post", "head", "put"]
permission_classes = [IsAuthenticatedOrCreate]
| 31.944444 | 62 | 0.786087 | 63 | 575 | 6.984127 | 0.634921 | 0.031818 | 0.054545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130435 | 575 | 17 | 63 | 33.823529 | 0.88 | 0 | 0 | 0 | 0 | 0 | 0.046957 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.384615 | 0 | 0.923077 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
cb5d6d1fc081eaeb9e9c206487da3b194f8b5249 | 3,984 | py | Python | flight_eyes.py | Eunoia/flight-eyes | 5b542b0a32a8f450e366e61e208c7c1a38a8e924 | [
"MIT"
] | null | null | null | flight_eyes.py | Eunoia/flight-eyes | 5b542b0a32a8f450e366e61e208c7c1a38a8e924 | [
"MIT"
] | null | null | null | flight_eyes.py | Eunoia/flight-eyes | 5b542b0a32a8f450e366e61e208c7c1a38a8e924 | [
"MIT"
] | null | null | null | """ Generates image over an area. """
import math
import os
import sys
import time
import requests
from PIL import Image
from shapely import geometry
from tiletanic.tilecover import cover_geometry
from tiletanic.tileschemes import WebMercator
def to_web_mercator(x_lon, y_lat):
""" Converts lat, long into web mercator. Needed for tiletanic. """
if abs(x_lon) >= 180 and abs(y_lat) > 90:
print 'Invalid coordinate values for conversion'
return None
num = x_lon * 0.017453292519943295
x = 6378137.0 * num
a = y_lat * 0.017453292519943295
x_mercator = x
y_mercator = 3189068.5 * math.log((1.0 + math.sin(a)) / (1.0 - math.sin(a)))
return (x_mercator, y_mercator)
def to_grid(tiles):
""" Organizes a list of tiles into a matrix that can be iterated over. """
tiles = sorted(tiles, key=lambda elem: elem.x)
pivot = 1
for idx, element in enumerate(tiles):
if idx == 0:
continue
prior_element = tiles[idx-1]
if element.x != prior_element.x:
pivot = idx
break
return [tiles[i:i+pivot] for i in range(0, len(tiles), pivot)]
def zoom_from_altitude(altitude):
""" converts altitude to zoom, really simplistic """
return round(math.log(35200000 / abs(altitude)) / math.log(2))
def url(quad):
""" creates the url for a given quadkey. """
key = 'AuZ2rzQL4BFpZbThyMutLjCSwreiFEPg66lx4ZTsbWIP2fvhEupamMwphvkb82sb'
root = 'http://ecn.t3.tiles.virtualearth.net/tiles'
return '{}/a{}.jpeg?g=195&mkt=en-US&key={}'.format(root, quad, key)
def load_image_from_url(quad):
""" Downloads image, and handles caching. """
date = time.strftime("%Y-%m-%d").split('-')
file_name = "quads/{}-{}-{}-{}.jpeg".format(quad, *date)
if os.path.exists(file_name):
image = Image.open(file_name)
else:
content = requests.get(url(quad)).content
open(file_name, 'w').write(content)
image = Image.open(file_name)
return image
def tiles_over(coordinates, altitude=0):
""" Finds all the tiles for an area """
quads = []
x_web_m, y_web_m = to_web_mercator(*coordinates)
zoom = zoom_from_altitude(altitude)
print zoom
tiler = WebMercator()
center_tile = tiler.tile(x_web_m, y_web_m, zoom)
bounding_box = tiler.bbox(center_tile)
tiles = cover_geometry(tiler, geometry.box(*bounding_box), zoom+2)
for row in to_grid(tiles):
quads.append([])
for cell in row:
quads[-1].append(tiler.quadkey(cell))
print '\n'.join(['|'.join([str(q) for q in quads])])
return quads
def download_tiles(quads, file_name):
""" Generates larger image from tiles. """
width, height = (len(quads[0]), len(quads))
full_size = Image.new('RGB', (width*256, height*256))
print "QUAD SHAPE x: %d y: %d" % (width, height)
for x_range in range(0, height):
for y_range in range(0, width):
print x_range, y_range
safety_i = min(x_range, len(quads))
safety_j = min(y_range, len(quads[0]))
quad = quads[safety_i][safety_j]
image = load_image_from_url(quad)
full_size.paste(image, (x_range*256, y_range*256))
full_size.save(file_name)
if __name__ == "__main__":
# print len(sys.argv)
if len(sys.argv) == 4:
location = [float(i) for s in sys.argv]
if len(sys.argv) == 3:
location = (float(sys.argv[1]), float(sys.argv[2]), 30000)
else:
print "python flight_eyes.py lon lat altitude(defaults to 30,000 ft)"
print "ex: python flight_eyes.py -122.39599 37.78858"
sys.exit()
lon, lat, alt = location
tiles = tiles_over((lon, lat), alt)
new_file_name = "background.jpg"
download_tiles(tiles, new_file_name)
wp = os.path.realpath(new_file_name)
os.system(
('osascript -e \'tell application "Finder" to set '
'desktop picture to POSIX file "{}"\'').format(wp, sep=2*'\n'))
| 33.2 | 80 | 0.634036 | 576 | 3,984 | 4.239583 | 0.340278 | 0.03276 | 0.009828 | 0.007371 | 0.066339 | 0.023751 | 0 | 0 | 0 | 0 | 0 | 0.044727 | 0.231175 | 3,984 | 119 | 81 | 33.478992 | 0.75253 | 0.004769 | 0 | 0.043956 | 1 | 0 | 0.124088 | 0.033689 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.098901 | null | null | 0.076923 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cb5f85512be8064d1a6670ce15ba0b607752300f | 1,836 | py | Python | src/TheLanguage/Lexer/Error.py | davidbrownell/DavidBrownell_TheLanguage | 07170b448a0ebd7fa2325c9ccd4cefdb3cf7eb98 | [
"BSL-1.0"
] | null | null | null | src/TheLanguage/Lexer/Error.py | davidbrownell/DavidBrownell_TheLanguage | 07170b448a0ebd7fa2325c9ccd4cefdb3cf7eb98 | [
"BSL-1.0"
] | null | null | null | src/TheLanguage/Lexer/Error.py | davidbrownell/DavidBrownell_TheLanguage | 07170b448a0ebd7fa2325c9ccd4cefdb3cf7eb98 | [
"BSL-1.0"
] | 1 | 2021-06-18T18:58:57.000Z | 2021-06-18T18:58:57.000Z | # ----------------------------------------------------------------------
# |
# | Error.py
# |
# | David Brownell <db@DavidBrownell.com>
# | 2021-09-22 15:42:41
# |
# ----------------------------------------------------------------------
# |
# | Copyright David Brownell 2021
# | Distributed under the Boost Software License, Version 1.0. See
# | accompanying file LICENSE_1_0.txt or copy at
# | http://www.boost.org/LICENSE_1_0.txt.
# |
# ----------------------------------------------------------------------
import os
from dataclasses import dataclass
import CommonEnvironment
from CommonEnvironment import Interface
# ----------------------------------------------------------------------
_script_fullpath = CommonEnvironment.ThisFullpath()
_script_dir, _script_name = os.path.split(_script_fullpath)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
@dataclass(frozen=True)
class Error(Exception, Interface.Interface):
"""Base class for all lexer-related errors"""
Line: int
Column: int
# ----------------------------------------------------------------------
def __post_init__(self):
assert self.Line >= 1, self.Line
assert self.Column >= 1, self.Column
# ----------------------------------------------------------------------
def __str__(self):
return self.MessageTemplate.format(**self.__dict__)
# ----------------------------------------------------------------------
@Interface.abstractproperty
def MessageTemplate(self):
"""Template used when generating the exception string"""
raise Exception("Abstract property") # pragma: no cover
| 36 | 79 | 0.410675 | 132 | 1,836 | 5.522727 | 0.621212 | 0.00823 | 0.024691 | 0.032922 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017264 | 0.179739 | 1,836 | 50 | 80 | 36.72 | 0.466799 | 0.558279 | 0 | 0 | 0 | 0 | 0.02332 | 0 | 0 | 0 | 0 | 0 | 0.111111 | 1 | 0.166667 | false | 0 | 0.222222 | 0.055556 | 0.611111 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
cb6b0fd874ec43ef1d962292ec79d55b571580f6 | 252 | py | Python | tests/cpydiff/modules_struct_fewargs.py | sebastien-riou/micropython | 116c15842fd48ddb77b0bc016341d936a0756573 | [
"MIT"
] | 13,648 | 2015-01-01T01:34:51.000Z | 2022-03-31T16:19:53.000Z | tests/cpydiff/modules_struct_fewargs.py | sebastien-riou/micropython | 116c15842fd48ddb77b0bc016341d936a0756573 | [
"MIT"
] | 7,092 | 2015-01-01T07:59:11.000Z | 2022-03-31T23:52:18.000Z | tests/cpydiff/modules_struct_fewargs.py | sebastien-riou/micropython | 116c15842fd48ddb77b0bc016341d936a0756573 | [
"MIT"
] | 4,942 | 2015-01-02T11:48:50.000Z | 2022-03-31T19:57:10.000Z | """
categories: Modules,struct
description: Struct pack with too few args, not checked by uPy
cause: Unknown
workaround: Unknown
"""
import struct
try:
print(struct.pack("bb", 1))
print("Should not get here")
except:
print("struct.error")
| 18 | 62 | 0.706349 | 35 | 252 | 5.085714 | 0.742857 | 0.11236 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004785 | 0.170635 | 252 | 13 | 63 | 19.384615 | 0.84689 | 0.492063 | 0 | 0 | 0 | 0 | 0.275 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.166667 | 0 | 0.166667 | 0.5 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
cb6dc459af92ac34acd40ec3e871b829d8f54554 | 3,935 | py | Python | mayi/test_case/test_landlord_read.py | 18701016443/mayi | 192c70c49a8e9e072b9d0d0136f02c653c589410 | [
"MIT"
] | null | null | null | mayi/test_case/test_landlord_read.py | 18701016443/mayi | 192c70c49a8e9e072b9d0d0136f02c653c589410 | [
"MIT"
] | null | null | null | mayi/test_case/test_landlord_read.py | 18701016443/mayi | 192c70c49a8e9e072b9d0d0136f02c653c589410 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# encoding: utf-8
"""
@version: python.3.6
@author: zhangjiaheng
@software: PyCharm
@time: 2017/9/26 14:31
"""
from test_case.page_obj import login_page,landlord_nav_page,landlord_read_page
from models import function,myunit
from time import sleep
import unittest
class TestLandlordRead(myunit.MyTest):
'''房源管理-房东必读'''
def test_agreement(self):
'''服务协议'''
login_page.LoginPage(self.driver).login()
sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).Iamlandlord()
sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).roommanager()
sleep(3)
po = landlord_read_page.LandlordReadPage(self.driver)
po.read()
sleep(3)
po.agreement()
print(po.agreement_text())
sleep(2)
function.insert_img(self.driver, "agreement.png")
def test_landlord_read(self):
'''房东规则'''
# login_page.LoginPage(self.driver).login()
# sleep(2)
landlord_nav_page.LandlordNavPage(self.driver).Iamlandlord()
sleep(2)
# landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
# sleep(2)
landlord_nav_page.LandlordNavPage(self.driver).roommanager()
sleep(2)
po = landlord_read_page.LandlordReadPage(self.driver)
po.read()
sleep(2)
function.insert_img(self.driver,"landlord_read.png")
def test_tenant_rule(self):
'''房客规则'''
# login_page.LoginPage(self.driver).login()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).Iamlandlord()
sleep(3)
# landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).roommanager()
sleep(3)
po = landlord_read_page.LandlordReadPage(self.driver)
po.read()
sleep(3)
po.tenant_rule()
function.insert_img(self.driver,"tenant_rule.png")
def test_roomauditrule(self):
'''房间审核规范'''
# login_page.LoginPage(self.driver).login()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).Iamlandlord()
sleep(3)
# landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).roommanager()
sleep(3)
po = landlord_read_page.LandlordReadPage(self.driver)
po.read()
sleep(3)
po.roomauditrule()
function.insert_img(self.driver, "roomauditrule.png")
def test_privacypolicy(self):
'''隐私条款'''
# login_page.LoginPage(self.driver).login()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).Iamlandlord()
sleep(3)
# landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
# sleep(3)
landlord_nav_page.LandlordNavPage(self.driver).roommanager()
sleep(3)
po = landlord_read_page.LandlordReadPage(self.driver)
po.read()
sleep(3)
po.privacypolicy()
print(po.privacypolicy_text())
function.insert_img(self.driver, "privacypolicy.png")
def test_disclaimer(self):
'''免责声明'''
# login_page.LoginPage(self.driver).login()
# sleep(3)
landlord_nav_page.LandlordNavPage( self.driver ).Iamlandlord()
sleep( 3 )
# landlord_nav_page.LandlordNavPage(self.driver).close_weiChat()
# sleep(3)
landlord_nav_page.LandlordNavPage( self.driver ).roommanager()
sleep( 3 )
po = landlord_read_page.LandlordReadPage( self.driver )
po.read()
sleep( 3 )
po.disclaimer()
print( po.disclaimer_text() )
function.insert_img( self.driver, "disclaimer.png" )
if __name__ == "__main__":
unittest.main()
| 30.742188 | 78 | 0.640407 | 440 | 3,935 | 5.511364 | 0.163636 | 0.148454 | 0.117526 | 0.22268 | 0.736907 | 0.714639 | 0.689072 | 0.650309 | 0.600825 | 0.57732 | 0 | 0.015 | 0.237611 | 3,935 | 127 | 79 | 30.984252 | 0.793333 | 0.197713 | 0 | 0.608108 | 0 | 0 | 0.032654 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.081081 | false | 0 | 0.054054 | 0 | 0.148649 | 0.040541 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 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 | 2 |
cb7a8c0810b94ad1d1042a8d4bb120890af0ef0a | 351 | py | Python | examples/song/factory.py | luiscastilho/toute | 56207d3d92b8bc1066e115c285cf79f96be3e249 | [
"MIT"
] | 3 | 2021-01-04T02:12:33.000Z | 2021-09-22T14:41:39.000Z | examples/song/factory.py | luiscastilho/toute | 56207d3d92b8bc1066e115c285cf79f96be3e249 | [
"MIT"
] | 6 | 2020-08-04T22:34:12.000Z | 2020-10-10T12:40:14.000Z | examples/song/factory.py | luiscastilho/toute | 56207d3d92b8bc1066e115c285cf79f96be3e249 | [
"MIT"
] | 1 | 2020-08-04T21:59:43.000Z | 2020-08-04T21:59:43.000Z | from elasticsearch import Elasticsearch
class ElasticSearchFactory(object):
def __init__(self, host: str, port: int):
self.host = host
self.port = port
def create(self) -> Elasticsearch:
return Elasticsearch(
[{'host': self.host, 'port': self.port}], headers={'X-Api-Key': 'xxxxx'} # optional
)
| 27 | 96 | 0.615385 | 38 | 351 | 5.578947 | 0.552632 | 0.113208 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.253561 | 351 | 12 | 97 | 29.25 | 0.80916 | 0.022792 | 0 | 0 | 0 | 0 | 0.064516 | 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 | 0 | 0 | 0 | 2 |
cb86ab2719ff071cd745e3c527186b958bf5515b | 882 | py | Python | src/users/models/microsoftgraphpending_operations.py | peombwa/Sample-Graph-Python-Client | 3396f531fbe6bb40a740767c4e31aee95a3b932e | [
"MIT"
] | null | null | null | src/users/models/microsoftgraphpending_operations.py | peombwa/Sample-Graph-Python-Client | 3396f531fbe6bb40a740767c4e31aee95a3b932e | [
"MIT"
] | null | null | null | src/users/models/microsoftgraphpending_operations.py | peombwa/Sample-Graph-Python-Client | 3396f531fbe6bb40a740767c4e31aee95a3b932e | [
"MIT"
] | null | null | null | # coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class MicrosoftgraphpendingOperations(Model):
"""pendingOperations.
:param pending_content_update:
:type pending_content_update:
~users.models.MicrosoftgraphpendingContentUpdate
"""
_attribute_map = {
'pending_content_update': {'key': 'pendingContentUpdate', 'type': 'MicrosoftgraphpendingContentUpdate'},
}
def __init__(self, pending_content_update=None):
super(MicrosoftgraphpendingOperations, self).__init__()
self.pending_content_update = pending_content_update
| 33.923077 | 112 | 0.620181 | 72 | 882 | 7.291667 | 0.666667 | 0.16 | 0.228571 | 0.08381 | 0.106667 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001319 | 0.14059 | 882 | 25 | 113 | 35.28 | 0.691293 | 0.49093 | 0 | 0 | 1 | 0 | 0.19715 | 0.133017 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.125 | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cb994b07e90e6d0d9374b19a28cc51cebc8a33e2 | 257 | py | Python | fundamentos/exer003.py | edelvandro/Python | 152685590af873bf63fcc5a29cf3528e4cc31a3e | [
"MIT"
] | 1 | 2020-04-14T14:43:59.000Z | 2020-04-14T14:43:59.000Z | fundamentos/exer003.py | edelvandro/Python | 152685590af873bf63fcc5a29cf3528e4cc31a3e | [
"MIT"
] | null | null | null | fundamentos/exer003.py | edelvandro/Python | 152685590af873bf63fcc5a29cf3528e4cc31a3e | [
"MIT"
] | null | null | null | # Crie um programa que leia dois números e mostre a soma entre eles.
num1 = int(input('Digite o primeiro valor: '))
num2 = int(input('Digite o segundo valor: '))
soma = num1 + num2
print('O resultado da soma entre {} e {} é: {}'.format(num1, num2, soma))
| 32.125 | 73 | 0.677043 | 42 | 257 | 4.142857 | 0.642857 | 0.103448 | 0.16092 | 0.172414 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.182879 | 257 | 7 | 74 | 36.714286 | 0.8 | 0.256809 | 0 | 0 | 0 | 0 | 0.465608 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.25 | 0 | 0 | 0 | null | 0 | 0 | 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 | 2 |
cba10bf7d8c9b99373be692d996d0ea2933d5dc5 | 12,810 | py | Python | train.py | JackMaguire/RobotsAsAGraph | 23208be8cfc34cd1f4db9f3cb7b680286e690f07 | [
"MIT"
] | null | null | null | train.py | JackMaguire/RobotsAsAGraph | 23208be8cfc34cd1f4db9f3cb7b680286e690f07 | [
"MIT"
] | null | null | null | train.py | JackMaguire/RobotsAsAGraph | 23208be8cfc34cd1f4db9f3cb7b680286e690f07 | [
"MIT"
] | null | null | null | import argparse
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.losses import BinaryCrossentropy
from tqdm import tqdm
import numpy as np
import robots_core
from robots_core.train import Tensors, make_tensors
import random
from scipy import sparse as sp
from spektral.data.utils import to_disjoint
from spektral.utils.sparse import sp_matrix_to_sp_tensor
from spektral.layers.ops.scatter import unsorted_segment_softmax
from spektral.layers import XENetConv, CrystalConv, ECCConv
from spektral.data.loaders import DisjointLoader
from spektral.data.dataset import Dataset
from spektral.data.dataset import Graph
import spektral
def test():
t = make_tensors( "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000010000000010000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000,0,1,8" )
print( t.input_tensors )
print( t.output_tensor )
def better_unsorted_segment_softmax(x, indices, mask):
n_nodes = tf.reduce_max(indices)+1
mask = tf.reshape( mask, tf.shape(x) )
#print( mask.shape )
#print( tf.exp( x ).shape )
e_x = mask * tf.exp(
x - tf.gather(tf.math.unsorted_segment_max(x, indices, n_nodes), indices)
)
e_x /= tf.gather(
tf.math.unsorted_segment_sum(e_x, indices, n_nodes) + 1e-9, indices
)
return e_x
'''
class RobotsDataset( Dataset ):
def __init__( self, filename ):
with open( filename ) as file:
self.samples = [line.rstrip() for line in file.readlines() if len(line) > 5]
print( "Loaded {} lines".format( len(self.samples) ) )
Dataset.__init__( self )
def read( self ):
return [ Graph( t.x, t.a, t.e, t.y ) ]
'''
class Loader( tf.keras.utils.Sequence ):
def __init__( self, filename, batch_size=64, shuffle=True ):
with open( filename ) as file:
self.samples = [line.rstrip() for line in file.readlines() if len(line) > 5]
print( "Loaded {} lines".format( len(self.samples) ) )
self.batch_size = batch_size
self.n_batches = int( len(self.samples) / batch_size )
self.shuffle = shuffle
self.on_epoch_end()
def __len__( self ):
return self.n_batches
def __getitem__( self, index ):
subsamples = self.samples[ index*self.batch_size : (index+1)*self.batch_size ]
Xs = []
As = []
Es = []
Os = []
for s in subsamples:
t = make_tensors( s )
Xs.append( np.asarray( t.input_tensors.x ) )
As.append( np.asarray( t.input_tensors.a ) )
Es.append( np.asarray( t.input_tensors.e ) )
Os.append( np.asarray( t.output_tensor ) )
#print( np.asarray( t.output_tensor ).shape )
#print( np.asarray( Os ) )
#print( np.asarray( Xs ).shape, "???" )
#print( np.asarray( Os ).shape, "!!!" )
x, a, e, i = to_disjoint( Xs, [sp.coo_matrix(a) for a in As], Es )
legal_move_mask = x[:, -1]
#print( legal_move_mask.shape )
#print( subsamples )
a = sp_matrix_to_sp_tensor(a)
#print( type(a) )
#print( type(a).__mro__ )
assert tf.keras.backend.is_sparse( a )
return [x, a, e, i, legal_move_mask], np.vstack( Os )
def on_epoch_end(self):
if self.shuffle:
random.shuffle( self.samples )
def build_model( nconv: int, compile: bool ):
F = 10
S = 8
Fh = 16 # Hidden Node
Sh = 16 # Hidden Edge
Skh = 32 # Hidden Stack
X_in = Input( name="X_in", shape=(F,) )
A_in = Input( name="A_in", shape=(None,), sparse=True )
E_in = Input( name="E_in", shape=(S,) )
I_in = Input( name="I_in", shape=(), dtype=tf.int32 )
L_in = Input( name="L_in", shape=() ) #Legal move mask
X = X_in
A = A_in
E = E_in
I = I_in
L = L_in
X = BatchNormalization()(X)
E = BatchNormalization()(E)
X = Dense( Fh, activation='relu' )(X)
E = Dense( Sh, activation='relu' )(E)
#print( X, A, E, I )
for i in range( 0, nconv ):
if( i == nconv-1 ):
edge_channels=0
else:
edge_channels=Sh
#'''
X, E = XENetConv( stack_channels=[Skh,Skh],
node_channels=Fh, edge_channels=edge_channels,
node_activation='relu', edge_activation='relu',
attention=True )( [X, A, E] )
#'''
#X = ECCConv( Fh, activation='relu' )( [ X, A, E ] )
X = Dense( Fh, activation='relu' )(X)
X = Dense( 1, activation=None )(X)
#X = Multiply()([X,L]) #Not Needed
X = better_unsorted_segment_softmax( X, I, L )
#X = Multiply()([X,L]) #Not Needed
Out = X
model = Model( inputs=[X_in,A_in,E_in,I_in,L_in], outputs=Out )
if compile:
model.compile( optimizer="adam", loss="binary_crossentropy" )
return model
def train_by_fit( model, training_loader, validation_loader ):
lr_callback = tf.keras.callbacks.ReduceLROnPlateau(
monitor="val_loss",
factor=0.1,
patience=2,
verbose=0,
mode="auto",
min_delta=0.001,
cooldown=0,
min_lr=0 )
stop = tf.keras.callbacks.EarlyStopping(monitor='val_loss', min_delta=0.002, patience=5, verbose=0, mode='min', baseline=None, restore_best_weights=True)
callbacks=[lr_callback,stop]
#history = model.fit( x=training_loader, validation_data=validation_loader, epochs=1000, shuffle=False, callbacks=callbacks, batch_size=1 )
#history = model.fit( x=training_loader, epochs=1000, shuffle=False, callbacks=callbacks, batch_size=1 )
'''
test_x = training_loader[0][0]
test_y = training_loader[0][1]
for i in range( 0, 5 ):
print( i, test_x[i].shape )
print( test_y.shape, sum(test_y) )
'''
def preview_preds( model, validation_loader, p ):
test_x, test_y = validation_loader[0]
x = model( test_x )
data = []
#print( x )
x = x.numpy()
for i in range( 0, len(x) ):
if( test_y[i][0] > 0.5 ):
if p:
print( x[i][0], test_x[-1][i], test_x[-2][i], test_y[i][0] )
else:
data.append( [ x[i][0], test_x[-1][i], test_x[-2][i], test_y[i][0] ] )
return np.asarray( data )
def evaluate_model( model, validation_loader, loss_fn ):
y_true = []
y_pred = []
for batch in validation_loader:
inputs, target = batch
p = model(inputs, training=False)
y_true.append(target)
y_pred.append(p.numpy())
y_true = np.vstack(y_true)
y_pred = np.vstack(y_pred)
return loss_fn(y_true, y_pred)
def train_by_hand( model, training_loader, validation_loader, model_name ):
#################
# Config
#################
learning_rate = 1e-4 # Learning rate
optimizer = Adam( learning_rate )
loss_fn = BinaryCrossentropy()
# see spektral/examples/graph_prediction/ogbg-mol-hiv_ecc.py
def train_step(inputs, target):
with tf.GradientTape() as tape:
predictions = model(inputs, training=True)
loss = loss_fn(target, predictions) + sum(model.losses)
gradients = tape.gradient(loss, model.trainable_variables)
optimizer.apply_gradients(zip(gradients, model.trainable_variables))
#print( "TRAIN LOSS", loss.numpy() )
return loss
min_loss = 9999
best_weights = model.get_weights()
epoch_for_min_loss = -1
epoch_for_last_lr_decrease = epoch_for_min_loss
for epoch in range( 0, 1000 ):
loss = 0
step = 0
for batch in tqdm(training_loader):
loss += train_step(*batch)
step += 1
#print( step, "/" , len(training_loader), " ... ", loss.numpy()/step )
validation_loss = evaluate_model( model, validation_loader, loss_fn )
#print( "VAL LOSS", validation_loss )
validation_loss_for_logic = np.round( 2*validation_loss, 4 )
validation_loss = np.round( validation_loss, 5 )
print("Epoch: {0} Training Loss: {1:.5f} Validation Loss: {2:.5f}".format(epoch, loss.numpy() / step, np.round( validation_loss, 5 )))
if epoch == 0:
# Freeze batch norm
for layer in model.layers:
if layer.name.startswith( "batch_normalization" ):
assert isinstance( layer, BatchNormalization )
print( "FREEZING", layer.name )
layer.trainable = False
layer._per_input_updates = {}
else:
assert not isinstance( layer, BatchNormalization )
if validation_loss_for_logic < min_loss:
print( "NEW MIN" )
min_loss = validation_loss_for_logic
best_weights = model.get_weights()
epoch_for_min_loss = epoch
model.save( model_name + ".checkpoint.h5" )
else:
if epoch - epoch_for_min_loss == 5:
return
elif epoch - epoch_for_min_loss >= 2 and epoch - epoch_for_last_lr_decrease >= 2:
print( "DECREASING LR" )
epoch_for_last_lr_decrease = epoch
learning_rate = learning_rate / 10.0
optimizer = Adam( learning_rate )
model.set_weights( best_weights )
def test2():
F = 10
S = 8
Fh = 16 # Hidden Node
Sh = 16 # Hidden Edge
Skh = 32 # Hidden Stack
X_in = Input( name="X_in", shape=(F,) )
A_in = Input( name="A_in", shape=(None,), sparse=True )
E_in = Input( name="E_in", shape=(S,) )
I_in = Input( name="I_in", shape=(), dtype=tf.int32 )
L_in = Input( name="L_in", shape=() ) #Legal move mask
X = X_in
A = A_in
E = E_in
I = I_in
L = L_in
X = BatchNormalization()(X)
E = BatchNormalization()(E)
X = Dense( 1, activation='relu' )(X)
E = Dense( 1, activation='relu' )(E)
Out = better_unsorted_segment_softmax( X, I, L )
#Out = unsorted_segment_softmax( X, I )
model = Model( inputs=[X_in,A_in,E_in,I_in,L_in], outputs=Out )
validation_loader = Loader( "data/validation_data.txt", shuffle = False, batch_size=4 )
#t = validation_loader[0]
inputs, target = validation_loader[0]
#print( inputs )
o = model( inputs )
for i in range( 0, len(inputs[-1]) ):
print( inputs[-2][i], inputs[-1][i], o[i][0].numpy() )
#print( inputs[0] )
#print( o )
if __name__ == '__main__':
#test2()
#exit( 0 )
parser = argparse.ArgumentParser()
parser.add_argument( "--model", help="Where should we save the output model?", required=True, type=str )
parser.add_argument( "--nconv", help="How Many XENet layers should we have?", required=True, type=int )
args = parser.parse_args()
training_loader = Loader( "data/training_data.txt" )
validation_loader = Loader( "data/validation_data.txt", shuffle = False )
model = build_model( args.nconv, compile=False )
model.summary()
train_by_hand( model, training_loader, validation_loader, args.model )
data1 = preview_preds( model, validation_loader, p=False )
model.save( args.model )
custom_objects = { "XENetConv": XENetConv }
model2 = load_model( args.model, custom_objects=custom_objects )
data2 = preview_preds( model2, validation_loader, p=False )
np.testing.assert_allclose( data1, data2 )
print( "Save/Load test passed!" )
| 35 | 1,382 | 0.64356 | 1,543 | 12,810 | 5.141931 | 0.182761 | 0.03025 | 0.013864 | 0.009453 | 0.294429 | 0.234308 | 0.189438 | 0.15881 | 0.147215 | 0.123015 | 0 | 0.152935 | 0.241998 | 12,810 | 365 | 1,383 | 35.09589 | 0.664161 | 0.088603 | 0 | 0.2 | 0 | 0.004348 | 0.163195 | 0.129143 | 0 | 1 | 0 | 0 | 0.017391 | 1 | 0.056522 | false | 0.004348 | 0.086957 | 0.004348 | 0.182609 | 0.043478 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cba7fa43d177eae0d28ebddd8abca5bee0b1be0e | 2,024 | py | Python | model/dataset.py | frankaging/Pragmatic-Color-Generation | e0e54d7638662f5206024a94d902b44dbed18c30 | [
"MIT"
] | 2 | 2020-10-09T04:14:10.000Z | 2020-10-16T02:20:50.000Z | model/dataset.py | frankaging/Pragmatic-Color-Generation | e0e54d7638662f5206024a94d902b44dbed18c30 | [
"MIT"
] | 11 | 2020-11-13T19:08:23.000Z | 2022-02-10T02:20:44.000Z | model/dataset.py | frankaging/Pragmatic-Color-Generation | e0e54d7638662f5206024a94d902b44dbed18c30 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# coding: utf-8
from util.color_util import *
# In[70]:
'''
Generate the dataset needed for the model
TODO: Put it in as a inherent of the base pytorch dataset class
'''
import os
import pickle
import numpy as np
import pandas as pd
import torch
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (4.0, 0.5)
import matplotlib.patches as mpatches
# In[2]:
BASE_DIR = "../munroe"
# ## Load labels, words and color mapping into memory
# In[78]:
# load label to word dictionary
label2words = {}
file_w2l = os.path.join(BASE_DIR, "words_to_labels.txt")
with open(file_w2l,encoding="utf-8") as f:
for line in f:
words, label = line.strip().split(',')
label2words[label] = words
# In[36]:
train, dev, test = load_splits()
# load color map
cdict_train = load_rgb(train)
cdict_dev = load_rgb(dev)
cdict_test = load_rgb(test)
# In[79]:
triple_train = load_triple(cdict_train, label2words)
triple_dev = load_triple(cdict_dev, label2words)
triple_test = load_triple(cdict_test, label2words)
# ## Saving all findings into disk for training use
# In[ ]:
import pickle
pickle.dump( triple_train, open( "../munroe/triple_train.p", "wb" ) )
pickle.dump( triple_dev, open( "../munroe/triple_dev.p", "wb" ) )
pickle.dump( triple_test, open( "../munroe/triple_test.p", "wb" ) )
pickle.dump( cdict_train, open( "../munroe/cdict_train.p", "wb" ) )
pickle.dump( cdict_dev, open( "../munroe/cdict_dev.p", "wb" ) )
pickle.dump( cdict_test, open( "../munroe/cdict_test.p", "wb" ) )
# non-extend version
triple_train_shrink = load_triple(cdict_train, label2words, extend=False)
triple_dev_shrink = load_triple(cdict_dev, label2words, extend=False)
triple_test_shrink = load_triple(cdict_test, label2words, extend=False)
pickle.dump( triple_train_shrink, open( "../munroe/triple_train_reduce.p", "wb" ) )
pickle.dump( triple_dev_shrink, open( "../munroe/triple_dev_reduce.p", "wb" ) )
pickle.dump( triple_test_shrink, open( "../munroe/triple_test_reduce.p", "wb" ) )
| 24.682927 | 83 | 0.714427 | 307 | 2,024 | 4.517915 | 0.325733 | 0.064888 | 0.045422 | 0.065609 | 0.253785 | 0.07354 | 0 | 0 | 0 | 0 | 0 | 0.01436 | 0.139822 | 2,024 | 81 | 84 | 24.987654 | 0.782309 | 0.119565 | 0 | 0.055556 | 1 | 0 | 0.176257 | 0.136281 | 0 | 0 | 0 | 0.012346 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cba88d266f588c17f07d7fe9d5d79c24430be689 | 327 | py | Python | tests/test_contactus.py | Himanshu-tester/Online_Shopping_Portal | 1299be0abea923fdb366603f9fb089902689d8d3 | [
"MIT"
] | null | null | null | tests/test_contactus.py | Himanshu-tester/Online_Shopping_Portal | 1299be0abea923fdb366603f9fb089902689d8d3 | [
"MIT"
] | null | null | null | tests/test_contactus.py | Himanshu-tester/Online_Shopping_Portal | 1299be0abea923fdb366603f9fb089902689d8d3 | [
"MIT"
] | null | null | null | import allure
import pytest
from page_objects.contact_page import Contact
@allure.feature("Contact Customer Support")
class TestContactUs:
@allure.story("Fill Customer Service Form")
#@pytest.mark.skip("Skip for now")
def test_contactus_page(self,driver):
c = Contact(driver)
c.contact_us_form()
| 23.357143 | 47 | 0.727829 | 43 | 327 | 5.395349 | 0.627907 | 0.060345 | 0.12069 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.174312 | 327 | 13 | 48 | 25.153846 | 0.859259 | 0.100917 | 0 | 0 | 0 | 0 | 0.170648 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
cbbf11b6c042ed2ba580e8d89736edecdaaf25f3 | 2,855 | py | Python | werckercli/tests/test_metrics.py | wercker/DEPRECATED-wercker-cli | 2df2bb02670f88b972eddc93c2cd8004572eb362 | [
"MIT"
] | 1 | 2019-04-16T22:09:57.000Z | 2019-04-16T22:09:57.000Z | werckercli/tests/test_metrics.py | wercker/DEPRECATED-wercker-cli | 2df2bb02670f88b972eddc93c2cd8004572eb362 | [
"MIT"
] | null | null | null | werckercli/tests/test_metrics.py | wercker/DEPRECATED-wercker-cli | 2df2bb02670f88b972eddc93c2cd8004572eb362 | [
"MIT"
] | 2 | 2017-10-04T08:03:50.000Z | 2021-03-26T12:42:46.000Z | import mock
from mock import ANY
import requests
from werckercli.metrics import track_application_startup, default_command_name
from werckercli.tests import TestCase
track_command_usage_path = "werckercli.metrics.track_command_usage"
class MetricsTests(TestCase):
def test_track_application_startup_fails_silently_on_ConnectionError(self):
err = requests.ConnectionError()
the_method = mock.Mock(side_effect=err)
with mock.patch(track_command_usage_path, the_method) as puts:
try:
track_application_startup()
except requests.ConnectionError:
self.fail("track_application_startup didn't fail silently")
def test_track_application_startup_calls_track_command_usage(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
the_method.assert_called_once()
@mock.patch("sys.argv", ['main.py'])
def test_track_application_startup_uses_default_command_on_empty_arg(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
the_method.assert_called_with(default_command_name, ANY)
@mock.patch("sys.argv", ['main.py', 'validate'])
def test_track_application_startup_passes_command_from_sys_args(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
the_method.assert_called_with('validate', ANY)
@mock.patch("sys.argv", [None, 'validate'])
def test_track_application_startup_handles_missing_script_arg(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
@mock.patch("sys.argv", [None, 'validate'])
def test_track_application_startup_handles_missing_script_arg(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
@mock.patch("sys.argv", [None, 'validate', 'foo', 'bar'])
def test_track_application_startup_passes_args(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
expected_args = ['foo', 'bar']
the_method.assert_called_with(ANY, expected_args)
@mock.patch("sys.argv", [None, 'validate'])
def test_track_application_startup_passes_None_for_missing_arguments(self):
the_method = mock.Mock()
with mock.patch(track_command_usage_path, the_method) as puts:
track_application_startup()
expected_args = None
the_method.assert_called_with(ANY, expected_args)
| 38.581081 | 79 | 0.709982 | 360 | 2,855 | 5.227778 | 0.175 | 0.100425 | 0.207758 | 0.100425 | 0.699256 | 0.648247 | 0.605739 | 0.579171 | 0.536663 | 0.536663 | 0 | 0 | 0.201751 | 2,855 | 73 | 80 | 39.109589 | 0.825801 | 0 | 0 | 0.527273 | 0 | 0 | 0.072154 | 0.022067 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.145455 | false | 0.054545 | 0.090909 | 0 | 0.254545 | 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 | 0 | 0 | 0 | 2 |
cbc07d3911d1e771e924754381d72ef7439f305f | 754 | py | Python | SENN/scripts/main_beer.py | ricokoff/FACT-AI | 393d3427435ca789f36702518483af4521883af3 | [
"MIT"
] | 1 | 2020-07-07T18:37:01.000Z | 2020-07-07T18:37:01.000Z | SENN/scripts/main_beer.py | ricokoff/FACT-AI | 393d3427435ca789f36702518483af4521883af3 | [
"MIT"
] | null | null | null | SENN/scripts/main_beer.py | ricokoff/FACT-AI | 393d3427435ca789f36702518483af4521883af3 | [
"MIT"
] | 1 | 2020-07-07T18:37:12.000Z | 2020-07-07T18:37:12.000Z | ''' Code for training and evaluating Self-Explaining Neural Networks.
Copyright (C) 2018 David Alvarez-Melis <dalvmel@mit.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
| 41.888889 | 70 | 0.775862 | 121 | 754 | 4.834711 | 0.669421 | 0.05641 | 0.066667 | 0.097436 | 0.140171 | 0.095727 | 0 | 0 | 0 | 0 | 0 | 0.008026 | 0.17374 | 754 | 17 | 71 | 44.352941 | 0.930979 | 0.970822 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cbc0fa5d32485bbc84c20c0654887f0b7d7a90c1 | 621 | py | Python | instagram_unfollower/localizer.py | someoneonearthwholovestg/Instagram_nabil | 77bade3352187ae49cba64134fcf814234ca3035 | [
"MIT"
] | 2 | 2021-03-23T01:06:05.000Z | 2022-01-08T14:39:16.000Z | instagram_unfollower/localizer.py | foevil/unf0llowers | d29f7eb2cdee959f2639d2f9922e7050a51d2323 | [
"MIT"
] | null | null | null | instagram_unfollower/localizer.py | foevil/unf0llowers | d29f7eb2cdee959f2639d2f9922e7050a51d2323 | [
"MIT"
] | 2 | 2021-03-23T01:00:36.000Z | 2021-04-22T12:01:30.000Z | import gettext
from typing import Optional
class Localizer:
def __init__(self, storage, languages: tuple):
self.storage = storage
self.languages = {lang: gettext.translation('base', localedir='locale', languages=[lang]).gettext
for lang in languages}
self.languages[None] = gettext.gettext # Default text
def get_locale(self, telegram_id: int):
lang = self.storage.get_language(telegram_id)
return self.languages[lang]
def set_locale(self, telegram_id: int, locale: Optional[str]):
self.storage.set_language(telegram_id, locale)
| 32.684211 | 105 | 0.674718 | 74 | 621 | 5.5 | 0.418919 | 0.108108 | 0.083538 | 0.09828 | 0.113022 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.227053 | 621 | 18 | 106 | 34.5 | 0.847917 | 0.019324 | 0 | 0 | 0 | 0 | 0.016474 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.153846 | 0 | 0.538462 | 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 | 0 | 1 | 0 | 0 | 2 |
1dae448dc7b91d1aa1ec3e4b205e933d71126288 | 710 | py | Python | release/stubs.min/System/ComponentModel/__init___parts/HandledEventArgs.py | htlcnn/ironpython-stubs | 780d829e2104b2789d5f4d6f32b0ec9f2930ca03 | [
"MIT"
] | 182 | 2017-06-27T02:26:15.000Z | 2022-03-30T18:53:43.000Z | release/stubs.min/System/ComponentModel/__init___parts/HandledEventArgs.py | htlcnn/ironpython-stubs | 780d829e2104b2789d5f4d6f32b0ec9f2930ca03 | [
"MIT"
] | 28 | 2017-06-27T13:38:23.000Z | 2022-03-15T11:19:44.000Z | release/stubs.min/System/ComponentModel/__init___parts/HandledEventArgs.py | htlcnn/ironpython-stubs | 780d829e2104b2789d5f4d6f32b0ec9f2930ca03 | [
"MIT"
] | 67 | 2017-06-28T09:43:59.000Z | 2022-03-20T21:17:10.000Z | class HandledEventArgs(EventArgs):
"""
Provides data for events that can be handled completely in an event handler.
HandledEventArgs()
HandledEventArgs(defaultHandledValue: bool)
"""
@staticmethod
def __new__(self,defaultHandledValue=None):
"""
__new__(cls: type)
__new__(cls: type,defaultHandledValue: bool)
"""
pass
Handled=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing.
Get: Handled(self: HandledEventArgs) -> bool
Set: Handled(self: HandledEventArgs)=value
"""
| 21.515152 | 157 | 0.715493 | 82 | 710 | 6.04878 | 0.573171 | 0.060484 | 0.040323 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.194366 | 710 | 32 | 158 | 22.1875 | 0.867133 | 0.292958 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.2 | 0 | 0 | 0.6 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
1db131ceb9b318a36727ee3e07b4b7e4ccacc7c8 | 6,674 | py | Python | Stroke.py | Suitceyes-Project-Code/Tactile-Brush-Python | 12da563d0988aa3b41c547ee9e1618f30c8b805c | [
"MIT"
] | null | null | null | Stroke.py | Suitceyes-Project-Code/Tactile-Brush-Python | 12da563d0988aa3b41c547ee9e1618f30c8b805c | [
"MIT"
] | null | null | null | Stroke.py | Suitceyes-Project-Code/Tactile-Brush-Python | 12da563d0988aa3b41c547ee9e1618f30c8b805c | [
"MIT"
] | 1 | 2021-10-04T14:27:25.000Z | 2021-10-04T14:27:25.000Z | from sortedcontainers import SortedSet
import math
EPSILON = 0.001
def cmp_to_key(mycmp):
'Convert a cmp= function into a key= function'
class K:
def __init__(self, obj, *args):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
return mycmp(self.obj, other.obj) > 0
def __eq__(self, other):
return mycmp(self.obj, other.obj) == 0
def __le__(self, other):
return mycmp(self.obj, other.obj) <= 0
def __ge__(self, other):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
return K
class Pair:
__slots__ = "first", "second"
def __repr__(self):
return "(" + str(self.first) + ", " + str(self.second) + ")"
class ActuatorPoint(Pair):
__slots__= "first", "second", "start", "durations", "timer_max_intensity"
def __init__(self, x : float, y : float):
self.first = x
self.second = y
self.timer_max_intensity = 0.0
self.durations = Pair()
self.start = 0.0
def get_duration(self):
return float(self.durations.first) + float(self.durations.second)
def get_start(self):
return self.start
def __key(self):
return (self.first, self.second)
def __repr__(self):
return "(" + str(self.first) + ", " + str(self.second) + ")"
def __str__(self):
return "Virtual actuator at position (" + str(self.first) + ", " + str(self.second) + ") cm" + \
" triggered at " + str(self.start) + " ms for " + str(self.get_duration()) + " msec. " + \
"Max intensity reached at " + str(self.timer_max_intensity) + " msec."
def __eq__(self, value):
if isinstance(value, ActuatorPoint):
return self.__key() == value.__key()
return NotImplemented
def __hash__(self):
return hash(self.__key())
def __gt__(self, value):
if self.first == value.first:
return self.second > value.second
return self.first > value.first
class Stroke:
__slots__ = "_startX", "_startY", "_endX", "_endY", "_duration", "_intensity", "_start", "_end", "_virtual_points"
def __init__(self, startX : float, startY : float, endX : float, endY : float, duration : float, intensity : float):
self._startX = startX
self._startY = startY
self._endX = endX
self._endY = endY
self._duration = duration
self._intensity = intensity
self._virtual_points = []
self._start = ActuatorPoint(0,0)
self._end = ActuatorPoint(0,0)
def compute_parameters(self, lines : float, columns : float, inter_dist : float):
self._compute_virtual_points(lines, columns, inter_dist)
self._compute_max_intensity_timers()
self._compute_durations_and_SOAs()
return self._virtual_points
def get_duration(self):
return self._duration
def get_intensity(self):
return self._intensity
def get_start(self):
return self._start
def get_end(self):
return self._end
def pretty_print(self):
for p in self._virtual_points:
print(str(p))
def _cmp(self, a : ActuatorPoint, b : ActuatorPoint):
diffX = b.first - a.first
if diffX > EPSILON:
return -1
return (1, -1)[abs(diffX) < EPSILON and b.second - a.second > EPSILON]
def _compute_virtual_points(self, lines : float, columns : float, inter_dist : float):
self._start = ActuatorPoint(self._startX * inter_dist, self._startY * inter_dist)
self._end = ActuatorPoint(self._endX * inter_dist, self._endY * inter_dist)
v = SortedSet(key = cmp_to_key(self._cmp))
v.add(self._start)
if abs(self._end.first - self._start.first) < EPSILON:
for l in range(0, lines):
c = ActuatorPoint(self._start.first, l * inter_dist)
if self._is_point_on_stroke(c):
v.add(c)
else:
coef = (self._end.second - self._start.second) / (self._end.first - self._start.first)
orig = self._start.second - coef * self._start.first
for l in range(0, lines):
y = l * inter_dist
ant = ActuatorPoint((y - orig)/coef, y)
if self._is_point_on_stroke(ant):
v.add(ant)
for c in range(0, columns):
x = c * inter_dist
res = ActuatorPoint(x, coef * x + orig)
if self._is_point_on_stroke(res):
v.add(res)
v.add(self._end)
self._virtual_points = list(v.islice(0, len(v)))
if self._start > self._end:
self._virtual_points = reversed(self._virtual_points)
def _compute_max_intensity_timers(self):
speed = math.hypot(self._start.first - self._end.first, self._start.second - self._end.second) / self._duration
begin = self._virtual_points[0]
for i in range(1, len(self._virtual_points)):
e = self._virtual_points[i]
e.timer_max_intensity = math.hypot(e.first - begin.first, e.second - begin.second) / speed
def _compute_durations_and_SOAs(self):
sumSOA = 0.0
self._virtual_points[0].start = 0
self._virtual_points[0].durations.first = 0
for i in range(0, len(self._virtual_points) -1):
current = self._virtual_points[i]
next = self._virtual_points[i + 1]
sumSOA += (0.32 * (current.durations.first - sumSOA + next.timer_max_intensity) + 47.3) / 1.32
next.start = sumSOA
next.durations.first = current.durations.second = next.timer_max_intensity - sumSOA
last = len(self._virtual_points) - 1
self._virtual_points[last].durations.first = self._duration - sumSOA
self._virtual_points[last].durations.second = 0
def _is_point_on_stroke(self, point : ActuatorPoint):
seg_dist = math.hypot(self._start.first - self._end.first, self._start.second - self._end.second)
start_to_point_dist = math.hypot(self._start.first - point.first, self._start.second - point.second)
point_to_end_dist = math.hypot(self._end.first - point.first, self._end.second - point.second)
return start_to_point_dist + point_to_end_dist - seg_dist < EPSILON
if __name__ == "__main__":
s = Stroke(0, 1, 3, 0, 1000, 1)
s.compute_parameters(1,3,2.5)
s.pretty_print() | 35.5 | 120 | 0.59979 | 848 | 6,674 | 4.404481 | 0.145047 | 0.048193 | 0.077376 | 0.032129 | 0.30656 | 0.217403 | 0.162517 | 0.162517 | 0.144846 | 0.111647 | 0 | 0.012539 | 0.283039 | 6,674 | 188 | 121 | 35.5 | 0.768025 | 0.006593 | 0 | 0.06993 | 0 | 0 | 0.041798 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.20979 | false | 0 | 0.013986 | 0.118881 | 0.454545 | 0.020979 | 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 | 0 | 0 | 0 | 2 |
1dbcf2ea42722e178d6932a337470ad2e6157f1a | 54 | py | Python | bg_biz/__init__.py | sluggard6/bgirl | 3c9fa895189ef16442694830d0c05cf60ee5187b | [
"Apache-2.0"
] | null | null | null | bg_biz/__init__.py | sluggard6/bgirl | 3c9fa895189ef16442694830d0c05cf60ee5187b | [
"Apache-2.0"
] | null | null | null | bg_biz/__init__.py | sluggard6/bgirl | 3c9fa895189ef16442694830d0c05cf60ee5187b | [
"Apache-2.0"
] | null | null | null | # -*- coding:utf-8 -*-
__author__ = [
'wufang'
]
| 9 | 22 | 0.481481 | 5 | 54 | 4.4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025 | 0.259259 | 54 | 5 | 23 | 10.8 | 0.525 | 0.37037 | 0 | 0 | 0 | 0 | 0.1875 | 0 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1defcbb806e9c17185681f2681e05c65ac36377f | 259 | py | Python | test.py | qibin0506/PyProgressBar | 70f49f062a996639cd237288fbb27b720e79628f | [
"Apache-2.0"
] | null | null | null | test.py | qibin0506/PyProgressBar | 70f49f062a996639cd237288fbb27b720e79628f | [
"Apache-2.0"
] | null | null | null | test.py | qibin0506/PyProgressBar | 70f49f062a996639cd237288fbb27b720e79628f | [
"Apache-2.0"
] | null | null | null | import time
from ProgressBar import ProgressBar
max_value = 50
progress_bar = ProgressBar(max_value)
for i in progress_bar():
progress_bar.progress(i, "already download {}%".format(int((i + 1) / max_value * 100)))
time.sleep(0.2)
progress_bar.end()
| 23.545455 | 91 | 0.725869 | 39 | 259 | 4.641026 | 0.564103 | 0.243094 | 0.209945 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036199 | 0.146718 | 259 | 10 | 92 | 25.9 | 0.782805 | 0 | 0 | 0 | 0 | 0 | 0.07722 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1df1adf0d18141e71f9af60e2f1a879b71049306 | 3,086 | py | Python | jobbing/models_remote/user_auth.py | davidall-amdocs/jobbing | b13311da07606366dfbe2eb737483a5820038557 | [
"Apache-2.0"
] | null | null | null | jobbing/models_remote/user_auth.py | davidall-amdocs/jobbing | b13311da07606366dfbe2eb737483a5820038557 | [
"Apache-2.0"
] | null | null | null | jobbing/models_remote/user_auth.py | davidall-amdocs/jobbing | b13311da07606366dfbe2eb737483a5820038557 | [
"Apache-2.0"
] | null | null | null | # coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from jobbing.models.base_model_ import Model
from jobbing import util
class UserAuth(Model):
def __init__(self,
user_auth_id:int = None,
user_auth_password:str = None,
user_auth_pass_date:str = None,
user_model_id:int = None,
user_auth_updated_date:str = None,
user_auth_name:str = None): # noqa: E501
self.swagger_types = {
'user_auth_id': int,
'user_auth_password': str,
'user_auth_pass_date': str,
'user_model_id': int,
'user_auth_updated_date': str,
'user_auth_name': str
}
self.attribute_map = {
'user_auth_id': 'user_auth_id',
'user_auth_password': 'user_auth_password',
'user_auth_pass_date': 'user_auth_pass_date',
'user_model_id': 'user_model_id',
'user_auth_updated_date': 'user_auth_updated_date',
'user_auth_name': 'user_auth_name'
}
self._user_auth_id = user_auth_id
self._user_auth_password = user_auth_password
self._user_auth_pass_date = user_auth_pass_date
self._user_model_id = user_model_id
self._user_auth_updated_date = user_auth_updated_date
self._user_auth_name = user_auth_name
@classmethod
def from_dict(cls, dikt) -> 'UserAuth':
return util.deserialize_model(dikt, cls)
@property
def user_auth_id(self) -> int:
return self._user_auth_id
@user_auth_id.setter
def user_auth_id(self, param):
if param is None:
raise ValueError("Invalid value for `user_auth_id`, must not be `None`") # noqa: E501
self._user_auth_id = param
@property
def user_auth_password(self) -> str:
return self._user_auth_password
@user_auth_password.setter
def user_auth_password(self, param):
if param is None:
raise ValueError("Invalid value for `user_auth_password`, must not be `None`") # noqa: E501
self._user_auth_password = param
@property
def user_auth_pass_date(self) -> str:
return self._user_auth_pass_date
@user_auth_pass_date.setter
def user_auth_pass_date(self, param):
if param is None:
raise ValueError("Invalid value for `user_auth_pass_date`, must not be `None`") # noqa: E501
self._user_auth_pass_date = param
@property
def user_model_id(self) -> int:
return self._user_model_id
@user_model_id.setter
def user_model_id(self, param):
if param is None:
raise ValueError("Invalid value for `user_model_id`, must not be `None`") # noqa: E501
self._user_model_id = param
@property
def user_auth_updated_date(self) -> str:
return self._user_auth_updated_date
@user_auth_updated_date.setter
def user_auth_updated_date(self, param):
if param is None:
raise ValueError("Invalid value for `user_auth_updated_date`, must not be `None`") # noqa: E501
self._user_auth_updated_date = param
@property
def user_auth_name(self) -> str:
return self._user_auth_name
@user_auth_name.setter
def user_auth_name(self, param):
if param is None:
raise ValueError("Invalid value for `user_auth_name`, must not be `None`") # noqa: E501
self._user_auth_name = param
| 28.054545 | 99 | 0.749838 | 486 | 3,086 | 4.347737 | 0.117284 | 0.227165 | 0.090866 | 0.090866 | 0.75911 | 0.626124 | 0.502603 | 0.378609 | 0.34548 | 0.209181 | 0 | 0.010753 | 0.156189 | 3,086 | 109 | 100 | 28.311927 | 0.800691 | 0.036293 | 0 | 0.139535 | 0 | 0 | 0.21607 | 0.04524 | 0 | 0 | 0 | 0 | 0 | 1 | 0.162791 | false | 0.232558 | 0.05814 | 0.081395 | 0.313953 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
1df313f3c6d294973317a9ce22da847fa27b99ef | 957 | py | Python | EPG_golom.py | Golom3402/September_2018 | 29d8ddca72a943aa6958de630fd0d898174fb4cd | [
"Apache-2.0"
] | null | null | null | EPG_golom.py | Golom3402/September_2018 | 29d8ddca72a943aa6958de630fd0d898174fb4cd | [
"Apache-2.0"
] | null | null | null | EPG_golom.py | Golom3402/September_2018 | 29d8ddca72a943aa6958de630fd0d898174fb4cd | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
from selenium.webdriver.chrome.webdriver import WebDriver
from time import sleep
import unittest
def is_alert_present(wd):
try:
wd.switch_to_alert().text
return True
except:
return False
class test_add_group(unittest.TestCase):
def setUp(self):
self.wd = WebDriver()
self.wd.implicitly_wait(60)
def Authorization(self):
success = True
wd = self.wd
wd.get("http://10.128.55.34:8080")
wd.find_element_by_id("id_username").click()
wd.find_element_by_id("id_username").clear()
wd.find_element_by_id("id_username").send_keys("admin")
wd.find_element_by_id("id_password").click()
wd.find_element_by_id("id_password").clear()
wd.find_element_by_id("id_password").send_keys("admin")
wd.find_element_by_css_selector("button[type=\"submit\"]").click()
def tearDown (self):
self.wd.quit() | 28.147059 | 74 | 0.649948 | 133 | 957 | 4.398496 | 0.458647 | 0.071795 | 0.155556 | 0.179487 | 0.381197 | 0.381197 | 0.381197 | 0 | 0 | 0 | 0 | 0.021333 | 0.216301 | 957 | 34 | 75 | 28.147059 | 0.758667 | 0.021944 | 0 | 0 | 0 | 0 | 0.121925 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0.115385 | 0.115385 | 0 | 0.384615 | 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 | 0 | 0 | 0 | 2 |
1df7f253fd5efe5b266943057a0be2ca078dbad2 | 2,069 | py | Python | mapping/enable/async_loader.py | enthought/enable-mapping | 7b77b2031405d5eadaec6da4d5b7927bffa3d999 | [
"BSD-3-Clause"
] | null | null | null | mapping/enable/async_loader.py | enthought/enable-mapping | 7b77b2031405d5eadaec6da4d5b7927bffa3d999 | [
"BSD-3-Clause"
] | 19 | 2016-01-21T23:06:01.000Z | 2018-05-31T04:05:03.000Z | mapping/enable/async_loader.py | enthought/enable-mapping | 7b77b2031405d5eadaec6da4d5b7927bffa3d999 | [
"BSD-3-Clause"
] | null | null | null | from abc import ABCMeta, abstractmethod
from threading import Event, Thread
from six.moves import queue
from six import with_metaclass
from traits.api import HasTraits, Any, Instance
class AsyncLoader(HasTraits):
""" A class which executes generic 'request' objects off of the main thread
"""
def start(self):
self._thread.start()
def stop(self):
self._stop_signal.set()
self._thread.join()
def put(self, request):
self._queue.put(request)
# Private interface ##################################################
_thread = Any
_stop_signal = Any
_queue = Instance(queue.Queue)
def __thread_default(self):
return RequestingThread(self._queue, self._stop_signal)
def __queue_default(self):
return queue.Queue()
def __stop_signal_default(self):
return Event()
class AsyncRequest(with_metaclass(ABCMeta, object)):
""" Interface for requests processed by AsyncLoader """
@abstractmethod
def execute(self):
""" Run the request
"""
class RequestingThread(Thread):
def __init__(self, queue_, stop_signal):
super(RequestingThread, self).__init__()
self.queue = queue_
self.stop_signal = stop_signal
self.daemon = True
def run(self):
# Wait for any requests
while not self.stop_signal.is_set():
try:
# Use a timeout so that `self.stop_signal` controls our exit
req = self.queue.get(block=True, timeout=1.0)
req.execute()
except queue.Empty:
pass
#: Global async_loader instance. Use get_global_async_loader
#: to request this instance.
_async_loader = None
def get_global_async_loader():
"""
Get the current global AsyncLoader instance,
creating and initializing it if necessary.
"""
global _async_loader
if _async_loader is None:
async_loader = AsyncLoader()
async_loader.start()
_async_loader = async_loader
return _async_loader
| 24.927711 | 79 | 0.636539 | 240 | 2,069 | 5.2375 | 0.366667 | 0.096261 | 0.055688 | 0.030231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001305 | 0.259546 | 2,069 | 82 | 80 | 25.231707 | 0.819191 | 0.205413 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.217391 | false | 0.021739 | 0.108696 | 0.065217 | 0.543478 | 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 | 0 | 1 | 0 | 0 | 2 |
1dfe86b8c5cd9281d0f80dc5ec07f6ff3621234b | 290 | py | Python | hxlm/core/urn/__init__.py | EticaAI/HXL-Data-Science-file-formats | c7c5aa56c452ac1613242ee04cc9ae66f38ec24d | [
"Unlicense"
] | 3 | 2021-01-25T20:44:10.000Z | 2021-04-19T22:47:05.000Z | hxlm/core/urn/__init__.py | fititnt/HXL-Data-Science-file-formats | f4fe9866e53280767f9cb4c8c488ef9c8b9d33cd | [
"Unlicense"
] | 24 | 2021-01-26T00:36:39.000Z | 2021-11-13T23:59:56.000Z | hxlm/core/urn/__init__.py | fititnt/HXL-Data-Science-file-formats | f4fe9866e53280767f9cb4c8c488ef9c8b9d33cd | [
"Unlicense"
] | 1 | 2021-09-05T03:43:37.000Z | 2021-09-05T03:43:37.000Z | """hxlm.core.urn
Author: 2021, Emerson Rocha (Etica.AI) <rocha@ieee.org>
License: Public Domain / BSD Zero Clause License
SPDX-License-Identifier: Unlicense OR 0BSD
"""
# __all__ = [
# 'get_entrypoint_type'
# ]
# from hxlm.core.io.util import ( # noqa
# get_entrypoint_type
# )
| 19.333333 | 55 | 0.689655 | 39 | 290 | 4.923077 | 0.794872 | 0.083333 | 0.177083 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020921 | 0.175862 | 290 | 14 | 56 | 20.714286 | 0.782427 | 0.924138 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3807c648c7e8c577f9f07493550985bf00ad698b | 1,301 | py | Python | src/modules/iam/domain/entities.py | pgorecki/python-ddd | 0073ccce35c651be263f5d7d3d63f9a49bc0b78a | [
"MIT"
] | 10 | 2022-03-16T19:26:51.000Z | 2022-03-31T23:50:51.000Z | src/modules/iam/domain/entities.py | pgorecki/python-ddd | 0073ccce35c651be263f5d7d3d63f9a49bc0b78a | [
"MIT"
] | null | null | null | src/modules/iam/domain/entities.py | pgorecki/python-ddd | 0073ccce35c651be263f5d7d3d63f9a49bc0b78a | [
"MIT"
] | 2 | 2022-03-16T19:26:54.000Z | 2022-03-27T13:21:02.000Z | from typing import Optional, List
from seedwork.domain.entities import Aggregate
from seedwork.domain.value_objects import UUID
from modules.iam.domain.value_objects import Session
ANONYMOUS_ID = UUID("00000000-0000-0000-0000-000000000000")
class User(Aggregate):
id: UUID
username: str
email: str = ""
hashed_password: str = ""
first_name: Optional[str] = ""
last_name: Optional[str] = ""
def change_main_attributes(
self,
username: str = None,
first_name: str = None,
last_name: str = None,
email: str = None,
):
if username:
self.username = username
if first_name:
self.first_name = first_name
if last_name:
self.last_name = last_name
if email:
self.email = email
def activate(self):
# TODO: maybe later
...
def deactivate(self):
# TODO: maybe later
...
def is_disabled(self):
return False
def is_anonymous(self):
return self.id == ANONYMOUS_ID
def is_active(self):
return not self.is_anonymous() and not self.is_disabled()
@classmethod
def Anonymous(cls):
return User(
id=ANONYMOUS_ID,
username="anonymous",
)
| 22.824561 | 65 | 0.596464 | 151 | 1,301 | 4.986755 | 0.337748 | 0.059761 | 0.047809 | 0.063745 | 0.055777 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035874 | 0.314374 | 1,301 | 56 | 66 | 23.232143 | 0.808296 | 0.026902 | 0 | 0.046512 | 0 | 0 | 0.035629 | 0.028504 | 0 | 0 | 0 | 0.017857 | 0 | 1 | 0.162791 | false | 0.023256 | 0.093023 | 0.093023 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
380a86f4c127e5609e2f3655de7c6c1b7ff361cc | 151 | py | Python | config/config.py | fujitako03/auto_podcast_share | 28018b47312fc82a2d1d202255406925a687f28e | [
"MIT"
] | null | null | null | config/config.py | fujitako03/auto_podcast_share | 28018b47312fc82a2d1d202255406925a687f28e | [
"MIT"
] | null | null | null | config/config.py | fujitako03/auto_podcast_share | 28018b47312fc82a2d1d202255406925a687f28e | [
"MIT"
] | 1 | 2021-02-10T16:08:44.000Z | 2021-02-10T16:08:44.000Z |
import os
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or "sqlite:///podcast.db"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY="9999"
| 21.571429 | 82 | 0.794702 | 21 | 151 | 5.428571 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028986 | 0.086093 | 151 | 6 | 83 | 25.166667 | 0.797101 | 0 | 0 | 0 | 0 | 0 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 | 0 | 0 | 0 | 2 |
381567161d5bb705100ac5ecc522eadb1932d918 | 188 | py | Python | app/setup.py | wulab/nd004-build-an-item-catalog | e3fd9b2ac94f4e074eb32d0ff6e8851a5a73dde8 | [
"MIT"
] | 1 | 2019-04-19T04:10:19.000Z | 2019-04-19T04:10:19.000Z | app/setup.py | wulab/nd004-build-an-item-catalog | e3fd9b2ac94f4e074eb32d0ff6e8851a5a73dde8 | [
"MIT"
] | null | null | null | app/setup.py | wulab/nd004-build-an-item-catalog | e3fd9b2ac94f4e074eb32d0ff6e8851a5a73dde8 | [
"MIT"
] | null | null | null | from setuptools import setup
setup(
name='ItemCatalog',
packages=['itemcatalog'],
include_package_data=True,
install_requires=[
'Flask',
'Jinja2'
],
)
| 15.666667 | 30 | 0.611702 | 17 | 188 | 6.588235 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007246 | 0.265957 | 188 | 11 | 31 | 17.090909 | 0.804348 | 0 | 0 | 0 | 0 | 0 | 0.175532 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.1 | 0 | 0.1 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
38452b9692abc07316dd6e6be7f38c40aaff161f | 103 | py | Python | smsapi/__init__.py | maciejga/smsapi-python-client | 6a3d05cf71ef14d0838341aa120808fa82ae2780 | [
"Apache-2.0"
] | null | null | null | smsapi/__init__.py | maciejga/smsapi-python-client | 6a3d05cf71ef14d0838341aa120808fa82ae2780 | [
"Apache-2.0"
] | null | null | null | smsapi/__init__.py | maciejga/smsapi-python-client | 6a3d05cf71ef14d0838341aa120808fa82ae2780 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
name = 'smsapi-client'
version = '2.3.0'
lib_info = '%s/%s' % (name, version) | 17.166667 | 36 | 0.553398 | 16 | 103 | 3.5 | 0.8125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.047059 | 0.174757 | 103 | 6 | 36 | 17.166667 | 0.611765 | 0.203884 | 0 | 0 | 0 | 0 | 0.283951 | 0 | 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 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3846fcf8a63fe65ff8773d9c266c68b9ce3e75ce | 550 | py | Python | django_comments_xtd/apps.py | dlrsp-dev/django-comments-xtd | 657ab26a8391ce14f83b4921d327b86f58e1ce22 | [
"BSD-2-Clause"
] | null | null | null | django_comments_xtd/apps.py | dlrsp-dev/django-comments-xtd | 657ab26a8391ce14f83b4921d327b86f58e1ce22 | [
"BSD-2-Clause"
] | null | null | null | django_comments_xtd/apps.py | dlrsp-dev/django-comments-xtd | 657ab26a8391ce14f83b4921d327b86f58e1ce22 | [
"BSD-2-Clause"
] | null | null | null | from django.apps import AppConfig
from django.db.models.signals import pre_save
class CommentsXtdConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'django_comments_xtd'
verbose_name = 'Comments Xtd'
def ready(self):
from django_comments_xtd import get_model
from django_comments_xtd.models import publish_or_unpublish_on_pre_save
model_app_label = get_model()._meta.label
pre_save.connect(publish_or_unpublish_on_pre_save,
sender=model_app_label)
| 32.352941 | 79 | 0.736364 | 73 | 550 | 5.164384 | 0.465753 | 0.106101 | 0.135279 | 0.111406 | 0.143236 | 0.143236 | 0 | 0 | 0 | 0 | 0 | 0 | 0.203636 | 550 | 16 | 80 | 34.375 | 0.860731 | 0 | 0 | 0 | 0 | 0 | 0.103636 | 0.047273 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.333333 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
698409c5430a29d8b364cf7035520c135d5ef8d3 | 528 | py | Python | brbanks2ynab/importers/alelo/alelo_alimentacao_card.py | andreroggeri/br-to-ynab | c5d0ef3804bb575badc05ac6dc771f6a9281f955 | [
"MIT"
] | 5 | 2021-09-20T13:15:37.000Z | 2022-03-01T01:03:27.000Z | brbanks2ynab/importers/alelo/alelo_alimentacao_card.py | andreroggeri/br-to-ynab | c5d0ef3804bb575badc05ac6dc771f6a9281f955 | [
"MIT"
] | 4 | 2021-04-28T14:11:42.000Z | 2021-10-09T16:18:15.000Z | brbanks2ynab/importers/alelo/alelo_alimentacao_card.py | andreroggeri/br-to-ynab | c5d0ef3804bb575badc05ac6dc771f6a9281f955 | [
"MIT"
] | 1 | 2021-09-27T15:13:30.000Z | 2021-09-27T15:13:30.000Z | from typing import Iterable
from python_alelo.alelo import TransactionsTime
from brbanks2ynab.importers.alelo.base_alelo_importer import BaseAleloImporter
from brbanks2ynab.importers.transaction import Transaction
class AleloAlimentacaoImporter(BaseAleloImporter):
def get_data(self) -> Iterable[Transaction]:
card = self._get_card_by_type('ALIMENTACAO')
response = self.alelo.get_transactions(card, TransactionsTime.LAST_THREE_MONTHS)
return map(self._to_transaction, response['transactions'])
| 35.2 | 88 | 0.806818 | 58 | 528 | 7.12069 | 0.534483 | 0.077482 | 0.121065 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00432 | 0.123106 | 528 | 14 | 89 | 37.714286 | 0.887689 | 0 | 0 | 0 | 0 | 0 | 0.043561 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.555556 | 0 | 0.888889 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
6987730a971fc7a137fc9b5f59554fafbf980dc7 | 275 | py | Python | app/app/core/config.py | finalsa/base-fastapi-api | 134a14c7bb7ec3d9f9c32beecae2ab8c51e820a3 | [
"MIT"
] | null | null | null | app/app/core/config.py | finalsa/base-fastapi-api | 134a14c7bb7ec3d9f9c32beecae2ab8c51e820a3 | [
"MIT"
] | null | null | null | app/app/core/config.py | finalsa/base-fastapi-api | 134a14c7bb7ec3d9f9c32beecae2ab8c51e820a3 | [
"MIT"
] | null | null | null | from utils import env_path
from pydantic import BaseSettings
class Settings(BaseSettings):
sql_user: str
sql_host: str
sql_password: str
sql_db: str
root_path: str = ''
celery_broker: str = 'redis://localhost:6379/0'
settings = Settings(env_path)
| 18.333333 | 51 | 0.709091 | 38 | 275 | 4.921053 | 0.578947 | 0.096257 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022936 | 0.207273 | 275 | 14 | 52 | 19.642857 | 0.834862 | 0 | 0 | 0 | 0 | 0 | 0.087273 | 0.087273 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.1 | 0.2 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
69887cb41864cfdc1a570b0f17117e712b65b516 | 320 | py | Python | pyvo/model/metadata.py | usersnap/pyvo | 35a4fe18b27256d5ef5b935fe707bb8fa0767aa9 | [
"MIT"
] | null | null | null | pyvo/model/metadata.py | usersnap/pyvo | 35a4fe18b27256d5ef5b935fe707bb8fa0767aa9 | [
"MIT"
] | null | null | null | pyvo/model/metadata.py | usersnap/pyvo | 35a4fe18b27256d5ef5b935fe707bb8fa0767aa9 | [
"MIT"
] | 4 | 2015-02-05T05:07:47.000Z | 2019-02-05T10:12:16.000Z | from base import PivotalResource, Instantiated, fields
class TimeZone(PivotalResource):
olson_name = fields.StringField()
offset = fields.StringField()
kind = fields.StringField()
class Label(Instantiated, PivotalResource):
project_id = fields.IntField()
name = fields.StringField(required=True)
| 24.615385 | 54 | 0.75 | 32 | 320 | 7.4375 | 0.59375 | 0.285714 | 0.176471 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15625 | 320 | 12 | 55 | 26.666667 | 0.881481 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
698898a77abdda8ac3f847c134d4c1b1d929c72e | 451 | py | Python | packratAgent/Container_test.py | pnhowe/packrat-agent | 49b69e8c6308362a8f729b1b3aea08dddb45c435 | [
"Apache-2.0"
] | null | null | null | packratAgent/Container_test.py | pnhowe/packrat-agent | 49b69e8c6308362a8f729b1b3aea08dddb45c435 | [
"Apache-2.0"
] | null | null | null | packratAgent/Container_test.py | pnhowe/packrat-agent | 49b69e8c6308362a8f729b1b3aea08dddb45c435 | [
"Apache-2.0"
] | null | null | null | import pytest
from packratAgent.Container import Container
def test_load():
Container( 'test_resources/docker-test_0.0.tar' )
with pytest.raises( ValueError ):
Container( 'test_resources/notexist' )
with pytest.raises( ValueError ):
Container( 'test_resources' )
def test_layers():
c = Container( 'test_resources/docker-test_0.0.tar' )
assert c.layers == [ 'c9677f6d879e9ff20694405684cc975f7b4fc71d6548ed76a38660da9b9b3cbb' ]
| 23.736842 | 91 | 0.75388 | 49 | 451 | 6.77551 | 0.408163 | 0.156627 | 0.26506 | 0.168675 | 0.512048 | 0.512048 | 0.512048 | 0.222892 | 0 | 0 | 0 | 0.115979 | 0.13969 | 451 | 18 | 92 | 25.055556 | 0.739691 | 0 | 0 | 0.181818 | 0 | 0 | 0.374723 | 0.343681 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.181818 | false | 0 | 0.181818 | 0 | 0.363636 | 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 | 0 | 0 | 0 | 2 |
699d1ad9c059195e0c47e225aeab4b76289264b7 | 3,144 | py | Python | mayan/apps/documents/icons.py | prezi/mayan-edms | e9bc10a056c3379b57115c6e83022f48c6298e1d | [
"Apache-2.0"
] | 4 | 2019-02-17T08:35:42.000Z | 2019-03-28T06:02:11.000Z | mayan/apps/documents/icons.py | zhoubear/mayan-edms | e9bc10a056c3379b57115c6e83022f48c6298e1d | [
"Apache-2.0"
] | 1 | 2018-10-11T13:01:34.000Z | 2018-10-11T13:01:34.000Z | mayan/apps/documents/icons.py | prezi/mayan-edms | e9bc10a056c3379b57115c6e83022f48c6298e1d | [
"Apache-2.0"
] | 3 | 2019-01-29T13:21:57.000Z | 2019-10-27T03:20:15.000Z | from __future__ import absolute_import, unicode_literals
from appearance.classes import Icon
icon_clear_image_cache = Icon(driver_name='fontawesome', symbol='file-image')
icon_dashboard_document_types = Icon(
driver_name='fontawesome', symbol='book'
)
icon_dashboard_documents_in_trash = Icon(
driver_name='fontawesome', symbol='trash'
)
icon_dashboard_pages_per_month = Icon(
driver_name='fontawesome', symbol='copy'
)
icon_dashboard_new_documents_this_month = Icon(
driver_name='fontawesome', symbol='calendar'
)
icon_dashboard_total_document = Icon(
driver_name='fontawesome', symbol='file'
)
icon_document_duplicates_list = Icon(
driver_name='fontawesome', symbol='clone'
)
icon_document_list = Icon(driver_name='fontawesome', symbol='file')
icon_document_list_deleted = Icon(driver_name='fontawesome', symbol='trash')
icon_document_list_favorites = Icon(driver_name='fontawesome', symbol='star')
icon_document_list_recent_access = Icon(
driver_name='fontawesome', symbol='clock'
)
icon_document_list_recent_added = Icon(
driver_name='fontawesome', symbol='asterisk'
)
icon_document_page_navigation_first = Icon(
driver_name='fontawesome', symbol='step-backward'
)
icon_document_page_navigation_last = Icon(
driver_name='fontawesome', symbol='step-forward'
)
icon_document_page_navigation_next = Icon(
driver_name='fontawesome', symbol='arrow-right'
)
icon_document_page_navigation_previous = Icon(
driver_name='fontawesome', symbol='arrow-left'
)
icon_document_page_return = Icon(driver_name='fontawesome', symbol='file')
icon_document_page_rotate_left = Icon(
driver_name='fontawesome', symbol='undo'
)
icon_document_page_rotate_right = Icon(
driver_name='fontawesome', symbol='redo'
)
icon_document_page_zoom_in = Icon(
driver_name='fontawesome', symbol='search-plus'
)
icon_document_page_zoom_out = Icon(
driver_name='fontawesome', symbol='search-minus'
)
icon_document_pages = Icon(driver_name='fontawesome', symbol='copy')
icon_document_preview = Icon(driver_name='fontawesome', symbol='eye')
icon_document_properties = Icon(driver_name='fontawesome', symbol='info')
icon_document_type_create = Icon(driver_name='fontawesome', symbol='plus')
icon_document_type_delete = Icon(driver_name='fontawesome', symbol='times')
icon_document_type_edit = Icon(driver_name='fontawesome', symbol='pencil-alt')
icon_document_type_setup = Icon(driver_name='fontawesome', symbol='file')
icon_document_type_filename = Icon(
driver_name='fontawesome', symbol='keyboard'
)
icon_document_type_filename_create = Icon(
driver_name='fontawesome', symbol='plus'
)
icon_document_version_list = Icon(
driver_name='fontawesome', symbol='code-branch'
)
icon_document_version_return_document = Icon(
driver_name='fontawesome', symbol='file'
)
icon_document_version_return_list = Icon(
driver_name='fontawesome', symbol='code-branch'
)
icon_duplicated_document_list = Icon(
driver_name='fontawesome', symbol='clone'
)
icon_duplicated_document_scan = Icon(
driver_name='fontawesome', symbol='clone'
)
icon_menu_documents = Icon(driver_name='fontawesome', symbol='file')
| 35.727273 | 78 | 0.788168 | 394 | 3,144 | 5.878173 | 0.213198 | 0.15544 | 0.217617 | 0.388601 | 0.617012 | 0.469775 | 0.328584 | 0.234456 | 0.135579 | 0 | 0 | 0 | 0.093511 | 3,144 | 87 | 79 | 36.137931 | 0.812632 | 0 | 0 | 0.083333 | 0 | 0 | 0.200064 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.02381 | 0 | 0.02381 | 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 | 0 | 0 | 0 | 2 |
69acec2e969036a9adecbdd35afcb235df6cfe4b | 934 | py | Python | django_geopostcodes/tests/test_helpers.py | alexhayes/django-geopostcodes | 325c7306e5939a576571e49b0889d08a0d138dfa | [
"MIT"
] | 2 | 2015-10-22T03:44:16.000Z | 2017-12-20T00:43:26.000Z | django_geopostcodes/tests/test_helpers.py | alexhayes/django-geopostcodes | 325c7306e5939a576571e49b0889d08a0d138dfa | [
"MIT"
] | null | null | null | django_geopostcodes/tests/test_helpers.py | alexhayes/django-geopostcodes | 325c7306e5939a576571e49b0889d08a0d138dfa | [
"MIT"
] | 1 | 2016-04-27T20:05:56.000Z | 2016-04-27T20:05:56.000Z | # -*- coding: utf-8 -*-
"""
django_geopostcodes.tests.test_helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test :py:module:`django_geopostcodes.helpers`.
"""
from __future__ import absolute_import, print_function, unicode_literals
import os
try:
# django 1.7
from django.utils.unittest import TestCase
except ImportError:
# django 1.8+
from django.test import TestCase
from ..helpers import import_localities
from ..models import Locality
def create_sample_localities():
import_localities(os.path.join(os.path.dirname(__file__),
'fixtures',
'Sample_GeoPC_AU_Places.csv'),
"\t")
class ImportLocalitiesTestCase(TestCase):
def test_import_localities(self):
self.assertEqual(Locality.objects.count(), 0)
create_sample_localities()
self.assertEqual(Locality.objects.count(), 100)
| 26.685714 | 72 | 0.630621 | 97 | 934 | 5.814433 | 0.525773 | 0.085106 | 0.078014 | 0.106383 | 0.124113 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012587 | 0.234475 | 934 | 34 | 73 | 27.470588 | 0.776224 | 0.183084 | 0 | 0 | 0 | 0 | 0.048583 | 0.035088 | 0 | 0 | 0 | 0 | 0.111111 | 1 | 0.111111 | false | 0 | 0.555556 | 0 | 0.722222 | 0.055556 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
69bb85f1fbbfd8762e60727698d21b25055ac9ab | 27,271 | py | Python | pysnmp-with-texts/CISCO-ENTITY-FRU-CONTROL-CAPABILITY.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 8 | 2019-05-09T17:04:00.000Z | 2021-06-09T06:50:51.000Z | pysnmp-with-texts/CISCO-ENTITY-FRU-CONTROL-CAPABILITY.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 4 | 2019-05-31T16:42:59.000Z | 2020-01-31T21:57:17.000Z | pysnmp-with-texts/CISCO-ENTITY-FRU-CONTROL-CAPABILITY.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 10 | 2019-04-30T05:51:36.000Z | 2022-02-16T03:33:41.000Z | #
# PySNMP MIB module CISCO-ENTITY-FRU-CONTROL-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ENTITY-FRU-CONTROL-CAPABILITY
# Produced by pysmi-0.3.4 at Wed May 1 11:57:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection")
ciscoAgentCapability, = mibBuilder.importSymbols("CISCO-SMI", "ciscoAgentCapability")
AgentCapabilities, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "AgentCapabilities", "ModuleCompliance", "NotificationGroup")
Integer32, iso, Unsigned32, Bits, ObjectIdentity, Gauge32, ModuleIdentity, TimeTicks, NotificationType, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, MibIdentifier, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "iso", "Unsigned32", "Bits", "ObjectIdentity", "Gauge32", "ModuleIdentity", "TimeTicks", "NotificationType", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "MibIdentifier", "IpAddress")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
ciscoEntityFruControlCapability = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 7, 264))
ciscoEntityFruControlCapability.setRevisions(('2011-09-25 00:00', '2009-12-14 00:00', '2009-07-30 00:00', '2009-03-25 00:00', '2009-03-11 00:00', '2008-10-28 00:00', '2008-03-24 00:00', '2007-09-06 00:00', '2007-08-31 00:00', '2007-07-19 00:00', '2006-06-21 00:00', '2006-04-19 00:00', '2006-03-16 00:00', '2006-01-31 00:00', '2005-07-12 00:00', '2005-03-09 00:00', '2004-09-15 00:00', '2004-01-15 00:00', '2003-09-15 00:00', '2002-03-20 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: ciscoEntityFruControlCapability.setRevisionsDescriptions(('Added capabilities ciscoEfcCapV15R0001SYPCat6K.', 'Added capability ciscoEfcCapV15R01TP39XXE', 'Added capabilities for ciscoEfcCapV12R04TP3925E, and ciscoEfcCapV12R04TP3945E', 'Added capabilities for ciscoEfcCapV12R04TP3845nv, ciscoEfcCapV12R04TP3825nv, ciscoEfcCapV12R04TP1941, ciscoEfcCapV12R04TP29XX, ciscoEfcCapV12R04TP3925 and ciscoEfcCapV12R04TP3945', 'The capability statement ciscoEfcCapIOSXRV3R08CRS1 has been added.', 'Added capabilities ciscoEfcCapV12R0233SXIPCat6K.', 'The capability statement ciscoEfcCapIOSXRV3R06CRS1 has been added.', 'Added capabilities ciscoEfcCapabilityV12R05TP32xx for 3200 platform.', 'Added capabilities ciscoEfcCapV12R0233SXHPCat6K.', 'Added capabilities ciscoEfcCapabilityV05R05PMGX8850 for MGX8850 platform.', '- Added capabilities ciscoEfcCapV12R05TP18xx and ciscoEfcCapV12R05TP2801 for IOS 12.4T on platforms 18xx and 2801.', '- Added Agent capabilities ciscoEfcCapACSWV03R000 for Cisco Application Control Engine (ACE).', '- Add VARIATIONs for notifications cefcModuleStatusChange, cefcPowerStatusChange, cefcFRUInserted and cefcFRURemoved in ciscoEfcCapabilityCatOSV08R0101, ciscoEfcCapabilityCatOSV08R0301 and ciscoEfcCapCatOSV08R0501.', '- Added ciscoEfcCapSanOSV21R1MDS9000 for SAN OS 2.1(1) on MDS 9000 series devices. - Added ciscoEfcCapSanOSV30R1MDS9000 for SAN OS 3.0(1) on MDS 9000 series devices.', '- Added ciscoEfcCapCatOSV08R0501.', '- Added capabilities ciscoEfcCapV12R04TP26XX ciscoEfcCapV12R04TP28XX, ciscoEfcCapV12R04TP3725, ciscoEfcCapV12R04TP3745, ciscoEfcCapV12R04TP3825, ciscoEfcCapV12R04TP3845, ciscoEfcCapV12R04TPIAD243X, ciscoEfcCapV12R04TPVG224 for IOS 12.4T on platforms 26xx, 28xx, 37xx, 38xx, IAD243x, VG224', '- Added ciscoEfcCapabilityV12R03P5XXX for IOS 12.3 on Access Server Platforms (AS5350, AS5400 and AS5850).', '- Added ciscoEfcCapV12RO217bSXACat6K. - Added ciscoEfcCapabilityCatOSV08R0301.', '- Added ciscoEfcCapabilityV12R0119ECat6K for IOS 12.1(19E) on Catalyst 6000/6500 and Cisco 7600 series devices. - Added ciscoEfcCapabilityV12RO217SXCat6K for IOS 12.2(17SX) on Catalyst 6000/6500 and Cisco 7600 series devices. - Added ciscoEfcCapabilityCatOSV08R0101 for Cisco CatOS 8.1(1).', 'Initial version of the MIB Module. - The ciscoEntityFruControlCapabilityV2R00 is for MGX8850 and BPX SES platform. - The ciscoEntityFRUControlCapabilityV12R00SGSR is for GSR platform.',))
if mibBuilder.loadTexts: ciscoEntityFruControlCapability.setLastUpdated('201109250000Z')
if mibBuilder.loadTexts: ciscoEntityFruControlCapability.setOrganization('Cisco Systems, Inc.')
if mibBuilder.loadTexts: ciscoEntityFruControlCapability.setContactInfo('Cisco Systems Customer Service Postal: 170 W Tasman Drive San Jose, CA 95134 USA Tel: +1 800 553-NETS E-mail: cs-snmp@cisco.com cs-lan-switch-snmp@cisco.com')
if mibBuilder.loadTexts: ciscoEntityFruControlCapability.setDescription('The Agent Capabilities for CISCO-ENTITY-FRU-CONTROL-MIB.')
ciscoEntityFruControlCapabilityV2R00 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 1))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEntityFruControlCapabilityV2R00 = ciscoEntityFruControlCapabilityV2R00.setProductRelease('MGX8850 Release 2.00,\n BPX SES Release 1.00')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEntityFruControlCapabilityV2R00 = ciscoEntityFruControlCapabilityV2R00.setStatus('current')
if mibBuilder.loadTexts: ciscoEntityFruControlCapabilityV2R00.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB Capabilities')
ciscoEntityFRUControlCapabilityV12R00SGSR = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 2))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEntityFRUControlCapabilityV12R00SGSR = ciscoEntityFRUControlCapabilityV12R00SGSR.setProductRelease('Cisco IOS 12.0S for GSR')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEntityFRUControlCapabilityV12R00SGSR = ciscoEntityFRUControlCapabilityV12R00SGSR.setStatus('current')
if mibBuilder.loadTexts: ciscoEntityFRUControlCapabilityV12R00SGSR.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities for GSR platform.')
ciscoEfcCapabilityV12R0119ECat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 3))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R0119ECat6K = ciscoEfcCapabilityV12R0119ECat6K.setProductRelease('Cisco IOS 12.1(19E) on Catalyst 6000/6500\n and Cisco 7600 series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R0119ECat6K = ciscoEfcCapabilityV12R0119ECat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityV12R0119ECat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapabilityV12RO217SXCat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 4))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12RO217SXCat6K = ciscoEfcCapabilityV12RO217SXCat6K.setProductRelease('Cisco IOS 12.2(17SX) on Catalyst 6000/6500\n and Cisco 7600 series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12RO217SXCat6K = ciscoEfcCapabilityV12RO217SXCat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityV12RO217SXCat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapabilityCatOSV08R0101 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 5))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityCatOSV08R0101 = ciscoEfcCapabilityCatOSV08R0101.setProductRelease('Cisco CatOS 8.1(1).')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityCatOSV08R0101 = ciscoEfcCapabilityCatOSV08R0101.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityCatOSV08R0101.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapV12RO217bSXACat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 6))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12RO217bSXACat6K = ciscoEfcCapV12RO217bSXACat6K.setProductRelease('Cisco IOS 12.2(17b)SXA on Catalyst 6000/6500\n and Cisco 7600 series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12RO217bSXACat6K = ciscoEfcCapV12RO217bSXACat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12RO217bSXACat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapabilityCatOSV08R0301 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 7))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityCatOSV08R0301 = ciscoEfcCapabilityCatOSV08R0301.setProductRelease('Cisco CatOS 8.3(1) on Catalyst 6000/6500\n and Cisco 7600 series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityCatOSV08R0301 = ciscoEfcCapabilityCatOSV08R0301.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityCatOSV08R0301.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapabilityV12R03P5XXX = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 8))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R03P5XXX = ciscoEfcCapabilityV12R03P5XXX.setProductRelease('Cisco IOS 12.3 for Access Server Platforms\n AS5350, AS5400 and AS5850.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R03P5XXX = ciscoEfcCapabilityV12R03P5XXX.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityV12R03P5XXX.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapV12R04TP3725 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 9))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3725 = ciscoEfcCapV12R04TP3725.setProductRelease('Cisco IOS 12.4T for c3725 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3725 = ciscoEfcCapV12R04TP3725.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3725.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapV12R04TP3745 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 10))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3745 = ciscoEfcCapV12R04TP3745.setProductRelease('Cisco IOS 12.4T for c3745 Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3745 = ciscoEfcCapV12R04TP3745.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3745.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP26XX = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 11))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP26XX = ciscoEfcCapV12R04TP26XX.setProductRelease('Cisco IOS 12.4T for c26xx XM Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP26XX = ciscoEfcCapV12R04TP26XX.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP26XX.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TPIAD243X = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 12))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TPIAD243X = ciscoEfcCapV12R04TPIAD243X.setProductRelease('Cisco IOS 12.4T for IAD 243x Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TPIAD243X = ciscoEfcCapV12R04TPIAD243X.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TPIAD243X.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TPVG224 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 13))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TPVG224 = ciscoEfcCapV12R04TPVG224.setProductRelease('Cisco IOS 12.4T for VG224 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TPVG224 = ciscoEfcCapV12R04TPVG224.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TPVG224.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP2691 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 14))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP2691 = ciscoEfcCapV12R04TP2691.setProductRelease('Cisco IOS 12.4T for c2691 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP2691 = ciscoEfcCapV12R04TP2691.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP2691.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP28XX = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 15))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP28XX = ciscoEfcCapV12R04TP28XX.setProductRelease('Cisco IOS 12.4T for c28xx Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP28XX = ciscoEfcCapV12R04TP28XX.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP28XX.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP3825 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 16))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3825 = ciscoEfcCapV12R04TP3825.setProductRelease('Cisco IOS 12.4T for c3825 Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3825 = ciscoEfcCapV12R04TP3825.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3825.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP3845 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 17))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3845 = ciscoEfcCapV12R04TP3845.setProductRelease('Cisco IOS 12.4T for c3845 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3845 = ciscoEfcCapV12R04TP3845.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3845.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapCatOSV08R0501 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 18))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapCatOSV08R0501 = ciscoEfcCapCatOSV08R0501.setProductRelease('Cisco CatOS 8.5(1) on Catalyst 6000/6500\n and Cisco 7600 series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapCatOSV08R0501 = ciscoEfcCapCatOSV08R0501.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapCatOSV08R0501.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapSanOSV21R1MDS9000 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 19))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapSanOSV21R1MDS9000 = ciscoEfcCapSanOSV21R1MDS9000.setProductRelease('Cisco SanOS 2.1(1) on Cisco MDS 9000 series\n devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapSanOSV21R1MDS9000 = ciscoEfcCapSanOSV21R1MDS9000.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapSanOSV21R1MDS9000.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapSanOSV30R1MDS9000 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 20))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapSanOSV30R1MDS9000 = ciscoEfcCapSanOSV30R1MDS9000.setProductRelease('Cisco SanOS 3.0(1) on Cisco MDS 9000 series\n devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapSanOSV30R1MDS9000 = ciscoEfcCapSanOSV30R1MDS9000.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapSanOSV30R1MDS9000.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapACSWV03R000 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 21))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapACSWV03R000 = ciscoEfcCapACSWV03R000.setProductRelease('ACSW (Application Control Software) 3.0')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapACSWV03R000 = ciscoEfcCapACSWV03R000.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapACSWV03R000.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapV12R05TP18xx = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 22))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R05TP18xx = ciscoEfcCapV12R05TP18xx.setProductRelease('Cisco IOS 12.5T for c18xx Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R05TP18xx = ciscoEfcCapV12R05TP18xx.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R05TP18xx.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R05TP2801 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 23))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R05TP2801 = ciscoEfcCapV12R05TP2801.setProductRelease('Cisco IOS 12.5T for c2801 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R05TP2801 = ciscoEfcCapV12R05TP2801.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R05TP2801.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapabilityV05R05PMGX8850 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 24))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV05R05PMGX8850 = ciscoEfcCapabilityV05R05PMGX8850.setProductRelease('MGX8850 Release 5.5')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV05R05PMGX8850 = ciscoEfcCapabilityV05R05PMGX8850.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityV05R05PMGX8850.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB Capabilities for the following modules of MGX8850: AXSM-XG, MPSM-T3E3-155, MPSM-16-T1E1, PXM1E, PXM45, VXSM and VISM.')
ciscoEfcCapV12R0233SXHPCat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 25))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R0233SXHPCat6K = ciscoEfcCapV12R0233SXHPCat6K.setProductRelease('Cisco IOS 12.2(33)SXH on Catalyst 6000/6500\n series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R0233SXHPCat6K = ciscoEfcCapV12R0233SXHPCat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R0233SXHPCat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapabilityV12R05TP32xx = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 26))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R05TP32xx = ciscoEfcCapabilityV12R05TP32xx.setProductRelease('Cisco IOS 12.5T for Cisco 3200 series routers')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapabilityV12R05TP32xx = ciscoEfcCapabilityV12R05TP32xx.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapabilityV12R05TP32xx.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities for 3220, 3250 and 3270 routers.')
ciscoEfcCapIOSXRV3R06CRS1 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 27))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapIOSXRV3R06CRS1 = ciscoEfcCapIOSXRV3R06CRS1.setProductRelease('Cisco IOS-XR Release 3.6 for CRS-1.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapIOSXRV3R06CRS1 = ciscoEfcCapIOSXRV3R06CRS1.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapIOSXRV3R06CRS1.setDescription('Agent capabilities for IOS-XR Release 3.6 for CRS-1.')
ciscoEfcCapV12R0233SXIPCat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 28))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R0233SXIPCat6K = ciscoEfcCapV12R0233SXIPCat6K.setProductRelease('Cisco IOS 12.2(33)SXI on Catalyst 6000/6500\n series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R0233SXIPCat6K = ciscoEfcCapV12R0233SXIPCat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R0233SXIPCat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
ciscoEfcCapIOSXRV3R08CRS1 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 29))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapIOSXRV3R08CRS1 = ciscoEfcCapIOSXRV3R08CRS1.setProductRelease('Cisco IOS-XR Release 3.8 for CRS-1.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapIOSXRV3R08CRS1 = ciscoEfcCapIOSXRV3R08CRS1.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapIOSXRV3R08CRS1.setDescription('Agent capabilities for IOS-XR Release 3.8 for CRS-1.')
ciscoEfcCapV12R04TP3845nv = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 30))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3845nv = ciscoEfcCapV12R04TP3845nv.setProductRelease('Cisco IOS 12.4(22)YB1 for c3845nv Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3845nv = ciscoEfcCapV12R04TP3845nv.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3845nv.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP3825nv = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 31))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3825nv = ciscoEfcCapV12R04TP3825nv.setProductRelease('Cisco IOS 12.4(22)YB1 for c3825nv Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3825nv = ciscoEfcCapV12R04TP3825nv.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3825nv.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP1941 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 32))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP1941 = ciscoEfcCapV12R04TP1941.setProductRelease('Cisco IOS 12.4T for c1941 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP1941 = ciscoEfcCapV12R04TP1941.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP1941.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP29XX = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 33))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP29XX = ciscoEfcCapV12R04TP29XX.setProductRelease('Cisco IOS 12.4T for c29xx Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP29XX = ciscoEfcCapV12R04TP29XX.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP29XX.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP3925 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 34))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3925 = ciscoEfcCapV12R04TP3925.setProductRelease('Cisco IOS 12.4T for c3925 Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3925 = ciscoEfcCapV12R04TP3925.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3925.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV12R04TP3945 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 35))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3945 = ciscoEfcCapV12R04TP3945.setProductRelease('Cisco IOS 12.4T for c3945 Platform')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV12R04TP3945 = ciscoEfcCapV12R04TP3945.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV12R04TP3945.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV15R01TP39XXE = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 36))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV15R01TP39XXE = ciscoEfcCapV15R01TP39XXE.setProductRelease('Cisco IOS 15.1T for c3925SPE200/c3925SPE250\n c3945SPE200/c3945SPE250 Platforms')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV15R01TP39XXE = ciscoEfcCapV15R01TP39XXE.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV15R01TP39XXE.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities')
ciscoEfcCapV15R0001SYPCat6K = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 264, 37))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV15R0001SYPCat6K = ciscoEfcCapV15R0001SYPCat6K.setProductRelease('Cisco IOS 15.0(1)SY on Catalyst 6000/6500 \n series devices.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoEfcCapV15R0001SYPCat6K = ciscoEfcCapV15R0001SYPCat6K.setStatus('current')
if mibBuilder.loadTexts: ciscoEfcCapV15R0001SYPCat6K.setDescription('CISCO-ENTITY-FRU-CONTROL-MIB capabilities.')
mibBuilder.exportSymbols("CISCO-ENTITY-FRU-CONTROL-CAPABILITY", ciscoEfcCapV12R04TP3745=ciscoEfcCapV12R04TP3745, ciscoEfcCapV12R04TP3925=ciscoEfcCapV12R04TP3925, ciscoEfcCapV12RO217bSXACat6K=ciscoEfcCapV12RO217bSXACat6K, ciscoEfcCapV12R04TPIAD243X=ciscoEfcCapV12R04TPIAD243X, ciscoEfcCapV12R05TP2801=ciscoEfcCapV12R05TP2801, ciscoEfcCapIOSXRV3R08CRS1=ciscoEfcCapIOSXRV3R08CRS1, PYSNMP_MODULE_ID=ciscoEntityFruControlCapability, ciscoEfcCapabilityV12R0119ECat6K=ciscoEfcCapabilityV12R0119ECat6K, ciscoEfcCapACSWV03R000=ciscoEfcCapACSWV03R000, ciscoEfcCapV12R04TP2691=ciscoEfcCapV12R04TP2691, ciscoEfcCapV12R04TP1941=ciscoEfcCapV12R04TP1941, ciscoEfcCapV12R04TP28XX=ciscoEfcCapV12R04TP28XX, ciscoEfcCapSanOSV21R1MDS9000=ciscoEfcCapSanOSV21R1MDS9000, ciscoEntityFruControlCapability=ciscoEntityFruControlCapability, ciscoEfcCapV15R0001SYPCat6K=ciscoEfcCapV15R0001SYPCat6K, ciscoEfcCapabilityCatOSV08R0101=ciscoEfcCapabilityCatOSV08R0101, ciscoEfcCapV12R04TPVG224=ciscoEfcCapV12R04TPVG224, ciscoEfcCapV12R04TP3845=ciscoEfcCapV12R04TP3845, ciscoEfcCapCatOSV08R0501=ciscoEfcCapCatOSV08R0501, ciscoEfcCapV12R04TP26XX=ciscoEfcCapV12R04TP26XX, ciscoEfcCapabilityV05R05PMGX8850=ciscoEfcCapabilityV05R05PMGX8850, ciscoEfcCapV12R04TP3725=ciscoEfcCapV12R04TP3725, ciscoEfcCapV12R04TP3825=ciscoEfcCapV12R04TP3825, ciscoEntityFRUControlCapabilityV12R00SGSR=ciscoEntityFRUControlCapabilityV12R00SGSR, ciscoEfcCapSanOSV30R1MDS9000=ciscoEfcCapSanOSV30R1MDS9000, ciscoEfcCapV12R0233SXHPCat6K=ciscoEfcCapV12R0233SXHPCat6K, ciscoEfcCapV15R01TP39XXE=ciscoEfcCapV15R01TP39XXE, ciscoEfcCapIOSXRV3R06CRS1=ciscoEfcCapIOSXRV3R06CRS1, ciscoEfcCapV12R05TP18xx=ciscoEfcCapV12R05TP18xx, ciscoEfcCapabilityV12RO217SXCat6K=ciscoEfcCapabilityV12RO217SXCat6K, ciscoEfcCapV12R04TP29XX=ciscoEfcCapV12R04TP29XX, ciscoEfcCapV12R04TP3945=ciscoEfcCapV12R04TP3945, ciscoEfcCapV12R0233SXIPCat6K=ciscoEfcCapV12R0233SXIPCat6K, ciscoEfcCapabilityV12R05TP32xx=ciscoEfcCapabilityV12R05TP32xx, ciscoEfcCapV12R04TP3825nv=ciscoEfcCapV12R04TP3825nv, ciscoEntityFruControlCapabilityV2R00=ciscoEntityFruControlCapabilityV2R00, ciscoEfcCapabilityV12R03P5XXX=ciscoEfcCapabilityV12R03P5XXX, ciscoEfcCapabilityCatOSV08R0301=ciscoEfcCapabilityCatOSV08R0301, ciscoEfcCapV12R04TP3845nv=ciscoEfcCapV12R04TP3845nv)
| 110.408907 | 2,443 | 0.771442 | 2,894 | 27,271 | 7.268832 | 0.111956 | 0.014261 | 0.067741 | 0.092698 | 0.612854 | 0.526478 | 0.495199 | 0.416477 | 0.397129 | 0.396606 | 0 | 0.161952 | 0.105643 | 27,271 | 246 | 2,444 | 110.857724 | 0.700533 | 0.013348 | 0 | 0.315126 | 0 | 0.046218 | 0.290431 | 0.086252 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.029412 | 0 | 0.029412 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
69d6522610d51eb21496328d36ff363d78f0cc7f | 1,235 | py | Python | src/classes/__init__.py | fedecalendino/binging-stonks | 80da73c501a490d44b5dfa1f45943d8ae0e0c613 | [
"MIT"
] | 1 | 2020-09-14T10:33:16.000Z | 2020-09-14T10:33:16.000Z | src/classes/__init__.py | fedecalendino/binging-stonks | 80da73c501a490d44b5dfa1f45943d8ae0e0c613 | [
"MIT"
] | null | null | null | src/classes/__init__.py | fedecalendino/binging-stonks | 80da73c501a490d44b5dfa1f45943d8ae0e0c613 | [
"MIT"
] | 1 | 2020-05-07T08:19:43.000Z | 2020-05-07T08:19:43.000Z | from slugify import slugify
class Episode:
def __init__(self, index, season, number, title, score):
self.index = index
self.season = season
self.number = number
self.title = title
self.score = score
@property
def label(self):
return f"{self.season:02d}x{self.number:02d}"
def __str__(self):
return f"{self.label}: {self.title}"
class Show:
def __init__(self, imdb_id: str, title: str, seasons: int):
self.imdb_id = imdb_id
self.title = title
self.slug = slugify(title)
self.plot = None
self.year = None
self.poster = None
self.rating = None
self.votes = None
self.seasons = {season: [] for season in range(1, seasons + 1)}
@property
def season_count(self):
return len(self.seasons)
@property
def episode_count(self):
return sum(map(len, self.seasons.values()))
def add_episode(self, season: int, episode: Episode):
self.seasons[season].append(episode)
@property
def url(self):
return f"https://www.imdb.com/title/{self.imdb_id}"
def __str__(self):
return f"({self.year}) {self.title} - {self.rating}"
| 23.75 | 71 | 0.597571 | 159 | 1,235 | 4.496855 | 0.295597 | 0.083916 | 0.061538 | 0.062937 | 0.058741 | 0.058741 | 0 | 0 | 0 | 0 | 0 | 0.006757 | 0.280972 | 1,235 | 51 | 72 | 24.215686 | 0.798423 | 0 | 0 | 0.216216 | 0 | 0 | 0.116599 | 0.02834 | 0 | 0 | 0 | 0 | 0 | 1 | 0.243243 | false | 0 | 0.027027 | 0.162162 | 0.486486 | 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 | 0 | 0 | 0 | 2 |
69df6a49f85c52c465cb70d0227ada39212e51ca | 1,333 | py | Python | src/model.py | kanekomasahiro/dict-debias | 3d2937286fe5a512b5b52e51615a787f9b734a12 | [
"MIT"
] | 2 | 2021-01-30T10:52:24.000Z | 2021-09-16T21:02:35.000Z | src/model.py | kanekomasahiro/dict-debias | 3d2937286fe5a512b5b52e51615a787f9b734a12 | [
"MIT"
] | null | null | null | src/model.py | kanekomasahiro/dict-debias | 3d2937286fe5a512b5b52e51615a787f9b734a12 | [
"MIT"
] | null | null | null | import torch
import torch.nn as nn
from torch import cuda
class GradReverse(torch.autograd.Function):
def __init__(self, lambd):
self.lambd = lambd
def forward(self, x):
return x.view_as(x)
def backward(self, grad_output):
return (grad_output * -self.lambd)
class Encoder(nn.Module):
def __init__(self, emb_size, hidden_size, dropout_rate=0.):
super(Encoder, self).__init__()
self.hidden_layer = nn.Linear(emb_size, hidden_size)
self.dropout = nn.Dropout(p=dropout_rate)
self.tanh = nn.Tanh()
def forward(self, emb):
hidden = self.tanh(self.hidden_layer(self.dropout(emb)))
return hidden
class Decoder(nn.Module):
def __init__(self, hidden_size, emb_size, dropout_rate=0., grad_reverse_flag=False):
super(Decoder, self).__init__()
self.output_layer = nn.Linear(hidden_size, emb_size)
self.grad_reverse_flag = grad_reverse_flag
self.dropout = nn.Dropout(p=dropout_rate)
self.tanh = nn.Tanh()
if self.grad_reverse_flag:
self.grad_reverse = GradReverse(-1)
def forward(self, hidden):
if self.grad_reverse_flag:
hidden = self.grad_reverse(hidden)
output = self.tanh(self.output_layer(self.dropout(hidden)))
return output
| 24.685185 | 88 | 0.657164 | 179 | 1,333 | 4.608939 | 0.223464 | 0.093333 | 0.090909 | 0.069091 | 0.208485 | 0.111515 | 0.111515 | 0.111515 | 0.111515 | 0.111515 | 0 | 0.002944 | 0.235559 | 1,333 | 53 | 89 | 25.150943 | 0.806673 | 0 | 0 | 0.181818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.212121 | false | 0 | 0.090909 | 0.060606 | 0.515152 | 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 | 0 | 1 | 0 | 0 | 2 |
69dfeabb0e21460af5f5681ea274047074c400ce | 917 | py | Python | mission/missions/old/2017/printer.py | cuauv/software | 5ad4d52d603f81a7f254f365d9b0fe636d03a260 | [
"BSD-3-Clause"
] | 70 | 2015-11-16T18:04:01.000Z | 2022-03-05T09:04:02.000Z | mission/missions/old/2017/printer.py | cuauv/software | 5ad4d52d603f81a7f254f365d9b0fe636d03a260 | [
"BSD-3-Clause"
] | 1 | 2016-08-03T05:13:19.000Z | 2016-08-03T06:19:39.000Z | mission/missions/old/2017/printer.py | cuauv/software | 5ad4d52d603f81a7f254f365d9b0fe636d03a260 | [
"BSD-3-Clause"
] | 34 | 2015-12-15T17:29:23.000Z | 2021-11-18T14:15:12.000Z | from mission.framework.task import Task
from mission.framework.timing import Timer
# TODO: Documentation!
class Printer(Task):
def __init__(self):
super().__init__()
self.timer_task = None # type: Task
def on_first_run(self, *args, **kwargs):
self.timer_task = Timer(5)
self.timer_task() # FIXME: This is because without a run, no parameter is passed?
print("First run called with args {} and kwargs {}.".format(args, kwargs))
def on_run(self, *args, **kwargs):
print("Running for {} seconds. Timer.is_finished(): {}".format(self.this_run_time - self.first_run_time,
self.timer_task.finished))
if self.timer_task.finished:
self.finish()
def on_finish(self, *args, **kwargs):
print("Finish called with args {} and kwargs {}.".format(args, kwargs)) | 38.208333 | 112 | 0.605234 | 114 | 917 | 4.675439 | 0.385965 | 0.084428 | 0.121951 | 0.06379 | 0.146341 | 0.146341 | 0.146341 | 0.146341 | 0 | 0 | 0 | 0.001502 | 0.273719 | 917 | 24 | 113 | 38.208333 | 0.798799 | 0.101418 | 0 | 0 | 0 | 0 | 0.16078 | 0 | 0 | 0 | 0 | 0.041667 | 0 | 1 | 0.235294 | false | 0 | 0.117647 | 0 | 0.411765 | 0.176471 | 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 | 0 | 0 | 0 | 2 |
69e20aa6019f34e30c2e8bdc1dfd421874240ce2 | 1,053 | py | Python | backend/app/api/db/baseClass.py | PY-GZKY/fastapi-crawl-admin | 6535054994d11e3c31b4caeae65e8fa0f495d2b7 | [
"MIT"
] | 13 | 2021-07-25T15:26:04.000Z | 2022-03-02T12:12:02.000Z | backend/app/api/db/baseClass.py | PY-GZKY/fastapi-crawl-admin | 6535054994d11e3c31b4caeae65e8fa0f495d2b7 | [
"MIT"
] | 1 | 2021-07-26T03:26:09.000Z | 2021-07-26T09:05:38.000Z | backend/app/api/db/baseClass.py | PY-GZKY/fastapi-crawl-admin | 6535054994d11e3c31b4caeae65e8fa0f495d2b7 | [
"MIT"
] | 3 | 2021-07-26T01:44:24.000Z | 2021-07-31T14:31:49.000Z | import uuid
from sqlalchemy.ext.declarative import as_declarative, declared_attr
@as_declarative()
class Base:
# 通用的字段
# id = Column(Integer, primary_key=True, index=True, autoincrement=True)
# create_time = Column(DateTime, default=datetime.now, server_default=func.now(), comment="创建时间")
# update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, server_default=func.now(),server_onupdate=func.now(), comment="更新时间")
# is_delete = Column(Integer, default=0, comment="逻辑删除:0=未删除,1=删除", server_default='0')
__name__: str
# Generate __tablename__ automatically
@declared_attr
def __tablename__(cls) -> str:
import re
# 如果没有指定__tablename__ 则默认使用model类名转换表名字
name_list = re.findall(r"[A-Z][a-z\d]*", cls.__name__)
# 表名格式替换成 下划线_格式 如 MallUser 替换成 mall_user
return "_".join(name_list).lower()
@declared_attr
def __table_args__(cls) -> dict:
return {'extend_existing': True} # 创建时跳过已创建的表
def gen_uuid() -> str:
return uuid.uuid4().hex
| 33.967742 | 151 | 0.694207 | 135 | 1,053 | 5.081481 | 0.555556 | 0.052478 | 0.052478 | 0.072886 | 0.1793 | 0.1793 | 0 | 0 | 0 | 0 | 0 | 0.0058 | 0.181387 | 1,053 | 30 | 152 | 35.1 | 0.790023 | 0.504274 | 0 | 0.133333 | 0 | 0 | 0.056641 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0.133333 | 0.733333 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
69fa7c5aea349367c3fcdcee4a19ce7b7132c235 | 4,191 | py | Python | backend/shop/migrations/0002_bookmark_cartitem_order_orderitem.py | mmohajer9/merchant | f76d81b9de6c0894bf62a26b07b7f9ea98ddd480 | [
"MIT"
] | 4 | 2021-07-31T17:10:55.000Z | 2021-11-08T12:55:37.000Z | backend/shop/migrations/0002_bookmark_cartitem_order_orderitem.py | mmohajer9/merchant | f76d81b9de6c0894bf62a26b07b7f9ea98ddd480 | [
"MIT"
] | null | null | null | backend/shop/migrations/0002_bookmark_cartitem_order_orderitem.py | mmohajer9/merchant | f76d81b9de6c0894bf62a26b07b7f9ea98ddd480 | [
"MIT"
] | null | null | null | # Generated by Django 3.2.4 on 2021-06-16 12:22
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('shop', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.CharField(choices=[('pending', 'pending'), ('finished', 'finished'), ('aborted', 'aborted')], max_length=100, verbose_name='Status')),
('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Created at')),
('updated_at', models.DateTimeField(auto_now=True, null=True, verbose_name='Updated at')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={
'verbose_name': 'Order',
'verbose_name_plural': 'Orders',
},
),
migrations.CreateModel(
name='OrderItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.IntegerField(default=1, verbose_name='Quantity')),
('price', models.DecimalField(decimal_places=2, max_digits=30, verbose_name='Order')),
('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Created at')),
('updated_at', models.DateTimeField(auto_now=True, null=True, verbose_name='Updated at')),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.order', verbose_name='Order')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.product', verbose_name='Product')),
],
options={
'verbose_name': 'Order Item',
'verbose_name_plural': 'Order Items',
},
),
migrations.CreateModel(
name='CartItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.IntegerField(default=1, verbose_name='Quantity of product')),
('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Created at')),
('updated_at', models.DateTimeField(auto_now=True, null=True, verbose_name='Updated at')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.product', verbose_name='Product')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={
'verbose_name': 'Cart Item',
'verbose_name_plural': 'Cart Items',
},
),
migrations.CreateModel(
name='Bookmark',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('description', models.CharField(blank=True, max_length=500, null=True, verbose_name='Description')),
('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Created at')),
('updated_at', models.DateTimeField(auto_now=True, null=True, verbose_name='Updated at')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.product', verbose_name='Product')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
],
options={
'verbose_name': 'Bookmark',
'verbose_name_plural': 'Bookmarks',
},
),
]
| 54.428571 | 168 | 0.605822 | 441 | 4,191 | 5.564626 | 0.204082 | 0.143439 | 0.055012 | 0.069682 | 0.673594 | 0.673594 | 0.673594 | 0.673594 | 0.673594 | 0.673594 | 0 | 0.009542 | 0.249821 | 4,191 | 76 | 169 | 55.144737 | 0.770992 | 0.010737 | 0 | 0.542857 | 1 | 0 | 0.160956 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.042857 | 0 | 0.085714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 2 |
0e078aacba03c5302ce071565e2930191f891c54 | 251 | py | Python | old/src/utils/views.py | Almazishe/portfolio | a69deded88e761ae06bf817646609c5237afb045 | [
"MIT"
] | null | null | null | old/src/utils/views.py | Almazishe/portfolio | a69deded88e761ae06bf817646609c5237afb045 | [
"MIT"
] | null | null | null | old/src/utils/views.py | Almazishe/portfolio | a69deded88e761ae06bf817646609c5237afb045 | [
"MIT"
] | null | null | null | import uuid
import os
def get_path(instance, filename, folder):
""" Function to make 'upload_to' value of ImageField's """
ext = filename.split('.')[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
return os.path.join(folder, filename)
| 22.818182 | 62 | 0.641434 | 35 | 251 | 4.542857 | 0.657143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009852 | 0.191235 | 251 | 10 | 63 | 25.1 | 0.773399 | 0.199203 | 0 | 0 | 0 | 0 | 0.031088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3852cc63b89c58d8ee6c55b86d7297667fc86e07 | 1,821 | py | Python | nettica_zonedump.py | eugenetaranov/mtools | 786817c22e3b22e5ad729fd494ffb9684eabee45 | [
"MIT"
] | null | null | null | nettica_zonedump.py | eugenetaranov/mtools | 786817c22e3b22e5ad729fd494ffb9684eabee45 | [
"MIT"
] | null | null | null | nettica_zonedump.py | eugenetaranov/mtools | 786817c22e3b22e5ad729fd494ffb9684eabee45 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
"""
Usage: zonedump.py <domain>
Dumps SOA, NS, A, MX, TXT records for the specified zone into file in nsupdate format
"""
netticauser = ''
netticapasswd = ''
netticaurl = 'https://www.nettica.com/DNS/DnsApi.asmx?WSDL'
server = '127.0.0.1'
zonestorage = ''
import base64
import sys
from suds.client import Client
from os import remove
def main(zone, netticauser, netticapasswd, netticaurl):
""" Main function """
netticapasswd = base64.b64encode(netticapasswd)
nettica = Client(netticaurl)
res = nettica.service.ListDomain(netticauser, netticapasswd, zone)
if res[0]['Status'] != 200:
print res[0]['Description']
sys.exit(1)
try:
with open('%s/%s.txt' % (zonestorage, zone), 'w+') as f:
f.write('server %s\n' % server)
f.write('zone %s\n' % zone)
for rec in res[2][0]:
if rec['HostName'] == None:
if rec['Priority'] == 0:
f.write('update add %s %s %s %s\n' % (rec['DomainName'], rec['TTL'], rec['RecordType'], rec['Data']))
else:
f.write('update add %s %s %s %s %s\n' % (rec['DomainName'], rec['TTL'], rec['RecordType'], rec['Priority'], rec['Data']))
else:
f.write('update add %s.%s %s %s %s\n' % (rec['HostName'], rec['DomainName'], rec['TTL'], rec['RecordType'], rec['Data']))
f.write('send\n')
except IndexError:
remove('%s/%s.txt' % (zonestorage, zone))
print 'No records found'
sys.exit(1)
return 0
if __name__ == '__main__':
if len(sys.argv) < 2:
print "Usage: %s <domain name>" % __file__
sys.exit(1)
else:
zone = sys.argv[1]
main(zone, netticauser, netticapasswd, netticaurl)
| 33.109091 | 145 | 0.557386 | 232 | 1,821 | 4.323276 | 0.392241 | 0.025922 | 0.023928 | 0.01994 | 0.316052 | 0.192423 | 0.192423 | 0.192423 | 0.138584 | 0.138584 | 0 | 0.019637 | 0.272927 | 1,821 | 54 | 146 | 33.722222 | 0.737915 | 0.010983 | 0 | 0.146341 | 0 | 0 | 0.21351 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.121951 | 0.097561 | null | null | 0.073171 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
3855ef063ae2b6891a87cede468280435c94e08e | 143 | py | Python | aiocloudflare/api/user/tokens/value/value.py | Stewart86/aioCloudflare | 341c0941f8f888a8b7e696e64550bce5da4949e6 | [
"MIT"
] | 2 | 2021-09-14T13:20:55.000Z | 2022-02-24T14:18:24.000Z | aiocloudflare/api/user/tokens/value/value.py | Stewart86/aioCloudflare | 341c0941f8f888a8b7e696e64550bce5da4949e6 | [
"MIT"
] | 46 | 2021-09-08T08:39:45.000Z | 2022-03-29T12:31:05.000Z | aiocloudflare/api/user/tokens/value/value.py | Stewart86/aioCloudflare | 341c0941f8f888a8b7e696e64550bce5da4949e6 | [
"MIT"
] | 1 | 2021-12-30T23:02:23.000Z | 2021-12-30T23:02:23.000Z | from aiocloudflare.commons.auth import Auth
class Value(Auth):
_endpoint1 = "user/tokens"
_endpoint2 = "value"
_endpoint3 = None
| 17.875 | 43 | 0.706294 | 16 | 143 | 6.125 | 0.8125 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026316 | 0.202797 | 143 | 7 | 44 | 20.428571 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0.111888 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 1 | 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 | 0 | 0 | 0 | 2 |
385d89663f3ccc25a51e5747a021938bff252675 | 515 | py | Python | alphaorm/generators/GeneratorInterface.py | emetowinner/python-alpha-orm | 045c77d93c7c75956f19d40565c0c806bd18b6c6 | [
"MIT"
] | 2 | 2019-12-06T05:18:31.000Z | 2020-11-07T01:53:51.000Z | alphaorm/generators/GeneratorInterface.py | emetowinner/python-alpha-orm | 045c77d93c7c75956f19d40565c0c806bd18b6c6 | [
"MIT"
] | 7 | 2020-04-12T23:18:16.000Z | 2020-09-30T17:41:09.000Z | alphaorm/generators/GeneratorInterface.py | emetowinner/python-alpha-orm | 045c77d93c7c75956f19d40565c0c806bd18b6c6 | [
"MIT"
] | 2 | 2019-12-06T05:18:31.000Z | 2020-09-29T09:45:03.000Z | import interface
class GeneratorInterface (interface.Interface):
@staticmethod
def checkColumnUpdates(columns_db, columns_record, alpha_record):
pass
@staticmethod
def creatNewColumns(dict_map, alpha_record, tablename):
pass
@staticmethod
def columns(columns_db, alpha_record, base=True):
pass
@staticmethod
def getGenerator(driver):
if driver == 'mysql':
from .MySQLGenerator import MySQLGenerator
return MySQLGenerator
| 22.391304 | 69 | 0.683495 | 48 | 515 | 7.1875 | 0.520833 | 0.173913 | 0.165217 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.252427 | 515 | 22 | 70 | 23.409091 | 0.896104 | 0 | 0 | 0.4375 | 0 | 0 | 0.009709 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.1875 | 0.125 | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
3860d4968c40125e1d11a5565a5692c38d6f09f6 | 970 | py | Python | databank/migrations/0002_auto_20200603_0613.py | IFRCGo/ifrcgo-api | c1c3e0cf1076ab48d03db6aaf7a00f8485ca9e1a | [
"MIT"
] | 11 | 2018-06-11T06:05:12.000Z | 2022-03-25T09:31:44.000Z | databank/migrations/0002_auto_20200603_0613.py | IFRCGo/ifrcgo-api | c1c3e0cf1076ab48d03db6aaf7a00f8485ca9e1a | [
"MIT"
] | 498 | 2017-11-07T21:20:13.000Z | 2022-03-31T14:37:18.000Z | databank/migrations/0002_auto_20200603_0613.py | IFRCGo/ifrcgo-api | c1c3e0cf1076ab48d03db6aaf7a00f8485ca9e1a | [
"MIT"
] | 6 | 2018-04-11T13:29:50.000Z | 2020-07-16T16:52:11.000Z | # Generated by Django 2.2.10 on 2020-06-03 06:13
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('databank', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='countryoverview',
options={'verbose_name': 'Country Overview', 'verbose_name_plural': 'Countries Overview'},
),
migrations.AlterModelOptions(
name='keyclimateevent',
options={'verbose_name': 'Key Client Event', 'verbose_name_plural': 'Key Client Events'},
),
migrations.AlterModelOptions(
name='seasonalcalender',
options={'verbose_name': 'Seasonal Calender Record', 'verbose_name_plural': 'Seasonal Calender Records'},
),
migrations.AlterModelOptions(
name='socialevent',
options={'verbose_name': 'Social Event', 'verbose_name_plural': 'Social Events'},
),
]
| 32.333333 | 117 | 0.618557 | 86 | 970 | 6.825581 | 0.488372 | 0.149915 | 0.211244 | 0.074957 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027894 | 0.260825 | 970 | 29 | 118 | 33.448276 | 0.790795 | 0.047423 | 0 | 0.347826 | 1 | 0 | 0.370933 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.043478 | 0 | 0.173913 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
386492f123c03dea502ee60e05364db5d25482bb | 1,988 | py | Python | classes/Puzzle.py | MadReza/AI-Puzzle-Solver | e922f4b299ba6ecf3f845ea50f404f98d2a4cfaa | [
"MIT"
] | null | null | null | classes/Puzzle.py | MadReza/AI-Puzzle-Solver | e922f4b299ba6ecf3f845ea50f404f98d2a4cfaa | [
"MIT"
] | null | null | null | classes/Puzzle.py | MadReza/AI-Puzzle-Solver | e922f4b299ba6ecf3f845ea50f404f98d2a4cfaa | [
"MIT"
] | null | null | null | """
Used as reference: http://codereview.stackexchange.com/a/76949
"""
from math import sqrt
class Puzzle:
def __init__(self, board):
self.board = board
self.width = int(sqrt(len(board))) #TODO need to make this squared puzzles
self.hole_position = board.index(0)
self.solvedBoard = range(1,self.width**2) + [0]
def __str__(self):
return "\n".join(str(self.board[start : start + self.width])
for start in range(0, len(self.board), self.width))
"""
Unique hash created by XOR of value and position on board
"""
def __hash__(self):
h = 0
for pos, value in enumerate(self.board):
h ^= pos << value
return h
def __eq__(self, other):
return self.board == other.board
"""
Expected solution is the empty spot to be at bottom right
Expecting:
3x3
1 2 3
4 5 6
7 8 0
"""
def solved(self):
return self.board == self.solvedBoard
def possible_moves(self):
moves = []
# Up, down
for dest in (self.hole_position - self.width, self.hole_position + self.width):
if 0 <= dest < len(self.board):
moves.append(dest)
# Left, right
for dest in (self.hole_position - 1, self.hole_position + 1):
if dest // self.width == self.hole_position // self.width:
moves.append(dest)
return moves
"""
Return new board with new position
"""
def move(self, destination):
board = self.board[:] #deep copy
if destination not in self.possible_moves():
raise AttributeError('destination is outside allowed moves', 'destination: ' + `destination`, 'Allowed: ' + `self.possible_moves()`)
board[self.hole_position], board[destination] = board[destination], board[self.hole_position]
return Puzzle(board)
| 27.232877 | 144 | 0.571429 | 245 | 1,988 | 4.526531 | 0.391837 | 0.073039 | 0.115419 | 0.054103 | 0.106402 | 0.106402 | 0.061317 | 0 | 0 | 0 | 0 | 0.01845 | 0.31841 | 1,988 | 72 | 145 | 27.611111 | 0.8 | 0.034205 | 0 | 0.058824 | 0 | 0 | 0.03886 | 0 | 0 | 0 | 0 | 0.013889 | 0 | 0 | null | null | 0 | 0.029412 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
387a824d90634546076bcbcd2e5055a2bf9364a9 | 715 | py | Python | setup.py | metazool/forambulator | a861636e90912273819b677706477fee68ae73bc | [
"BSD-3-Clause"
] | 2 | 2020-02-14T21:58:43.000Z | 2020-02-19T18:22:00.000Z | setup.py | metazool/forambulator | a861636e90912273819b677706477fee68ae73bc | [
"BSD-3-Clause"
] | null | null | null | setup.py | metazool/forambulator | a861636e90912273819b677706477fee68ae73bc | [
"BSD-3-Clause"
] | null | null | null | from setuptools import setup
setup(
name='forambulator',
version='0.1.0',
description='Generate synthetic forams',
url='https://github.com/metazool/forambulator',
author='Jo Walsh',
license='BSD 3-clause',
packages=['forambulator'],
install_requires=['numpy',
'requests',
'scikit-image',
'stylegan2-pytorch'
],
classifiers=[
'Development Status :: 1 - Planning',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.5',
],
)
| 27.5 | 53 | 0.532867 | 61 | 715 | 6.229508 | 0.852459 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016771 | 0.332867 | 715 | 25 | 54 | 28.6 | 0.779874 | 0 | 0 | 0.090909 | 1 | 0 | 0.470588 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.045455 | 0 | 0.045455 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3888b0a28d3d8e2c65a7dc1e735fc51cdc110566 | 2,367 | py | Python | account.py | murungiKirima/password_locker | 91313bfa9b0750a2e05fc98756185d92e3e3403a | [
"MIT"
] | null | null | null | account.py | murungiKirima/password_locker | 91313bfa9b0750a2e05fc98756185d92e3e3403a | [
"MIT"
] | null | null | null | account.py | murungiKirima/password_locker | 91313bfa9b0750a2e05fc98756185d92e3e3403a | [
"MIT"
] | null | null | null | class User:
user_list = []
def __init__(self,f_name,l_name,password):
"""function that creates user object"""
self.f_name = f_name
self.l_name = l_name
self.password = password
def save_user(self):
"""function that saves users"""
User.user_list.append(self)
def delete_user(self):
"""function that deletes users"""
User.user_list.remove(self)
@classmethod
def display_user(self):
"""function that displays users"""
return User.user_list
@classmethod
def find_user_by_name(cls,name):
"""function that finds users by name"""
for user in cls.user_list:
if user.f_name == name:
return user
@classmethod
def user_exist(cls,f_name):
"""function that checks if users exists"""
for user in cls.user_list:
if user.f_name == f_name:
return True
return False
class Credentials:
def __init__ (self,user_name, credential_name , credential__password):
"""function that creates credentials"""
self.user_name = user_name
self.credential_name =credential_name
self.credential_password =credential__password
list_of_credentials = []
def save_credentials(self):
"""function that saves credentials"""
self.list_of_credentials.append(self)
def delete_credentials(self):
"""function that deletes credentials"""
Credentials.list_of_credentials.remove(self)
@classmethod
def find_by_name(cls, user_name):
"""Method that takes in a name and returns a credential that matches that particular name
Args:
name: account_name that has a password
Returns:
The account_name and it's corresponding PassWord
"""
for credential in cls.list_of_credentials:
if credential.user_name == user_name:
return credential
@classmethod
def credential_exists(cls,name):
"""function that checks if credentials exists"""
for credential in cls.list_of_credentials:
if credential.user_name == name:
return True
@classmethod
def display_all_credentials(cls):
"""function that displays Credentials"""
return cls.list_of_credentials
| 29.222222 | 97 | 0.632446 | 282 | 2,367 | 5.070922 | 0.195035 | 0.092308 | 0.071329 | 0.041958 | 0.153846 | 0.12028 | 0.12028 | 0.12028 | 0.12028 | 0.12028 | 0 | 0 | 0.287283 | 2,367 | 80 | 98 | 29.5875 | 0.847659 | 0.237854 | 0 | 0.255319 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.255319 | false | 0.085106 | 0 | 0 | 0.489362 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
389562825dc2a4e5f9b7a6f77aaad2f42bc1b875 | 600 | py | Python | demo_schoolOrSociety/schoolOrSociety/urls.py | luckyLQL/SchoolOrSociety | 011444864b6a36b79e8365d0962f84d40ae80fc4 | [
"MIT"
] | null | null | null | demo_schoolOrSociety/schoolOrSociety/urls.py | luckyLQL/SchoolOrSociety | 011444864b6a36b79e8365d0962f84d40ae80fc4 | [
"MIT"
] | null | null | null | demo_schoolOrSociety/schoolOrSociety/urls.py | luckyLQL/SchoolOrSociety | 011444864b6a36b79e8365d0962f84d40ae80fc4 | [
"MIT"
] | null | null | null | from django.conf.urls import url
from django.views.generic import TemplateView
from . import views
from schoolOrSociety.views import index, questionary, result, process
urlpatterns = [
url(r'^questionary', views.questionary, {'template_name': 'schoolOrSociety/questionary.html'}, name='questionary'),
url(r'^result', views.result, name='result'),
url(r'^process', views.process, name='process'),
url(r'^index', views.index, {'template_name': 'schoolOrSociety/index.html'}, name='index'),
url(r'^.?', views.index, {'template_name': 'schoolOrSociety/index.html'}, name='index'),
]
| 46.153846 | 119 | 0.718333 | 73 | 600 | 5.863014 | 0.260274 | 0.046729 | 0.189252 | 0.102804 | 0.257009 | 0.257009 | 0.257009 | 0.257009 | 0.257009 | 0 | 0 | 0 | 0.108333 | 600 | 12 | 120 | 50 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0.321667 | 0.14 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.363636 | 0 | 0.363636 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
389677181d341e843f1157b7178363de8c588ba2 | 775 | py | Python | src/homework/tests/cross_check/tests_crosscheck_is_checked.py | denkasyanov/education-backend | c796b6f2f1cc1cd09f83cab2ca0cc45344906ef5 | [
"MIT"
] | 151 | 2020-04-21T09:58:57.000Z | 2021-09-12T09:01:21.000Z | src/homework/tests/cross_check/tests_crosscheck_is_checked.py | denkasyanov/education-backend | c796b6f2f1cc1cd09f83cab2ca0cc45344906ef5 | [
"MIT"
] | 163 | 2020-05-29T20:52:00.000Z | 2021-09-11T12:44:56.000Z | src/homework/tests/cross_check/tests_crosscheck_is_checked.py | boochamoocha/education-backend | c6ffb0c00bc066c8f1e0a8c0ffe4d0215c7c416a | [
"MIT"
] | 39 | 2020-04-21T12:28:16.000Z | 2021-09-12T15:33:47.000Z | import pytest
pytestmark = [pytest.mark.django_db]
@pytest.fixture
def answer(answers):
return answers[0]
@pytest.fixture
def crosscheck(mixer, answer, another_user):
return mixer.blend('homework.AnswerCrossCheck', answer=answer, checker=another_user)
def test_not_by_default(crosscheck):
assert crosscheck.is_checked() is False
def test_checked_if_there_are_comments_from_checker(crosscheck, mixer, another_user, answer):
mixer.blend('homework.Answer', parent=answer, author=another_user)
assert crosscheck.is_checked() is True
def test_not_checked_if_answers_are_not_children_of_the_checked_answer(crosscheck, mixer, another_user, answer):
mixer.blend('homework.Answer', author=another_user)
assert crosscheck.is_checked() is False
| 25.833333 | 112 | 0.793548 | 105 | 775 | 5.561905 | 0.371429 | 0.113014 | 0.092466 | 0.128425 | 0.416096 | 0.416096 | 0.35274 | 0.35274 | 0.35274 | 0 | 0 | 0.001458 | 0.114839 | 775 | 29 | 113 | 26.724138 | 0.849854 | 0 | 0 | 0.25 | 0 | 0 | 0.070968 | 0.032258 | 0 | 0 | 0 | 0 | 0.1875 | 1 | 0.3125 | false | 0 | 0.0625 | 0.125 | 0.5 | 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 | 0 | 0 | 0 | 2 |
38a2d491bbcee718741e3cb717dbbf6479dbe644 | 6,148 | py | Python | dtor/opts.py | Tevien/dtor | bb2954074d4a299c129d44afd722084980b792b5 | [
"MIT"
] | null | null | null | dtor/opts.py | Tevien/dtor | bb2954074d4a299c129d44afd722084980b792b5 | [
"MIT"
] | 1 | 2021-03-12T10:57:24.000Z | 2021-03-12T10:57:24.000Z | dtor/opts.py | Tevien/dtor | bb2954074d4a299c129d44afd722084980b792b5 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""Process all the options"""
__author__ = "Sean Benson"
__copyright__ = "MIT"
import json
import argparse
norms = {
'torchvision_3d': ([0.43216, 0.394666, 0.37645],
[0.22803, 0.22145, 0.216989]),
'torchvision_2d': ([0.485, 0.456, 0.406],
[0.229, 0.224, 0.225])
}
def init_parser():
parser = argparse.ArgumentParser()
parser.add_argument('--num-workers',
help='Number of worker processes for background data loading',
default=2,
type=int,
nargs='?',
)
parser.add_argument('--batch-size',
help='Batch size to use for training',
default=32,
type=int,
nargs='?',
)
parser.add_argument('--epochs',
help='Number of epochs to train for',
default=1,
type=int,
nargs='?',
)
parser.add_argument('--seed',
help='Reproduce results with a certain seed',
default=42,
type=int,
nargs='?',
)
parser.add_argument('--exp_name',
default='test',
nargs='?',
help="Experiment name, will be used for model saving and logs",
)
parser.add_argument('--datapoints',
help="Location of the CSV with our points and labels",
type=str,
nargs='?',
default="data/chunked.csv",
)
parser.add_argument('--loss',
help="What kind of loss function to use",
type=str,
nargs='?',
default="crossentropy",
)
parser.add_argument('--model',
help="Which model do we want",
type=str,
nargs='?',
default="nominal",
)
parser.add_argument('--load_json',
help="Specify args with a json",
type=str,
nargs='?',
default="",
)
parser.add_argument('--best_json',
help="Specify args with best hyperparams",
type=str,
nargs='?',
default="",
)
parser.add_argument('--dset',
help="Which dataset to use",
type=str,
nargs='?',
default="ltp",
)
parser.add_argument('--augments',
help="How many rounds of augmentations",
type=int,
nargs='?',
default="0",
)
parser.add_argument('--resume',
help="Checkpoint to resume from",
type=str,
nargs='?',
default="",
)
parser.add_argument('--pretrain_loc',
help="Feature extraction pretrained location",
type=str,
nargs='?',
default="",
)
parser.add_argument('--pretrained_2d_name',
help="Which 2d pretrained model to use",
type=str,
nargs='?',
default="",
)
parser.add_argument('--dim',
help="Dimensions of input data",
type=int,
nargs='?',
default=3,
)
parser.add_argument('--sam',
help="Do we want to turn on the SAM overfitting protection",
type=bool,
nargs='?',
default=False,
)
parser.add_argument('--dset_lim',
help="How many data points to we want (MNIST OPTION ONLY)",
type=int,
nargs='?',
default=150,
)
parser.add_argument('--earlystopping',
help="Early stopping to avoid overfitting, 0=off, n>0 is patience",
type=int,
nargs='?',
default=3,
)
parser.add_argument('--num_trials',
help="How many trials for the tuning",
type=int,
nargs='?',
default=10,
)
parser.add_argument('--mode',
help="train | tune",
type=str,
nargs='?',
default="train",
)
parser.add_argument('--fix_nlayers',
help="How many layers of the input model do we fix",
type=int,
nargs='?',
default=0,
)
parser.add_argument('--rn_depth',
help="How big a resnet do you want",
type=int,
nargs='?',
default=101,
)
parser.add_argument('--rn_nclasses',
help="How many classes were in the original training",
type=int,
nargs='?',
default=700,
)
return parser
| 37.260606 | 91 | 0.357352 | 459 | 6,148 | 4.686275 | 0.359477 | 0.100418 | 0.189679 | 0.088331 | 0.252441 | 0.231055 | 0.152487 | 0.068805 | 0 | 0 | 0 | 0.032063 | 0.543429 | 6,148 | 164 | 92 | 37.487805 | 0.734236 | 0.007482 | 0 | 0.339744 | 0 | 0 | 0.199147 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.00641 | false | 0 | 0.012821 | 0 | 0.025641 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 2 |
38a445fb915ea7c6a07d9f8e89c1561ae4caae15 | 275 | py | Python | data_collection/gazette/spiders/sp_sao_roque.py | kaiocp/querido-diario | 86004049c6eee305e13066cf3607d30849bb099a | [
"MIT"
] | 454 | 2018-04-07T03:32:57.000Z | 2020-08-17T19:56:22.000Z | data_collection/gazette/spiders/sp_sao_roque.py | kaiocp/querido-diario | 86004049c6eee305e13066cf3607d30849bb099a | [
"MIT"
] | 254 | 2020-08-18T14:09:43.000Z | 2022-03-28T11:30:51.000Z | data_collection/gazette/spiders/sp_sao_roque.py | kaiocp/querido-diario | 86004049c6eee305e13066cf3607d30849bb099a | [
"MIT"
] | 183 | 2018-04-11T15:09:37.000Z | 2020-08-15T18:55:11.000Z | from gazette.spiders.base.instar import BaseInstarSpider
class SpSaoRoqueSpider(BaseInstarSpider):
TERRITORY_ID = "3550605"
name = "sp_sao_roque"
allowed_domains = ["saoroque.sp.gov.br"]
start_urls = ["https://www.saoroque.sp.gov.br/portal/diario-oficial"]
| 30.555556 | 73 | 0.741818 | 34 | 275 | 5.852941 | 0.823529 | 0.100503 | 0.130653 | 0.150754 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029289 | 0.130909 | 275 | 8 | 74 | 34.375 | 0.803347 | 0 | 0 | 0 | 0 | 0 | 0.323636 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 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 | 0 | 1 | 0 | 0 | 2 |
38a7e2da98e7128cff9b5ed98e45e6601349f73f | 1,445 | py | Python | ext/ace_in_gf/tools/make_gf_parse_lin_command.py | TeamSPoon/logicmoo_nlu | 5c3e5013a3048da7d68a8a43476ad84d3ea4bb47 | [
"MIT"
] | 6 | 2020-01-27T12:08:02.000Z | 2020-02-28T19:30:28.000Z | pack/logicmoo_nlu/prolog/ace_in_gf/tools/make_gf_parse_lin_command.py | logicmoo/old_logicmoo_workspace | 44025b6e389e2f2f7d86b46c1301cab0604bba26 | [
"MIT"
] | 1 | 2020-02-02T13:12:34.000Z | 2020-02-02T13:12:34.000Z | ext/ace_in_gf/tools/make_gf_parse_lin_command.py | TeamSPoon/logicmoo_nlu | 5c3e5013a3048da7d68a8a43476ad84d3ea4bb47 | [
"MIT"
] | null | null | null | #! /usr/bin/env python
# Author: Kaarel Kaljurand
# Version: 2013-02-21
#
# Example:
# $ echo "hallo" | python make_gf_parse_lin_command.py --lang=Ger --cat=Phrase
# p -lang=Ger -cat=Phrase "hallo" | l -treebank
import sys
import argparse
def process_lines(lang_in, lang_out, cat):
for line in sys.stdin:
line = line.strip()
process_line(lang_in, lang_out, cat, line)
def process_line(lang_in, lang_out, cat, line):
serialize_command(lang_in, lang_out, cat, line)
# TODO: add escaping
def serialize_command(lang_in, lang_out, cat, line):
print 'p -lang={:} -cat={:} "{:}" | l -lang={:} -treebank'.format(lang_in, cat, line, lang_out)
parser = argparse.ArgumentParser(description='Makes a GF parse + linearize command')
parser.add_argument('-l', '--lang-in',
type=str, action='store', dest='lang_in',
default='Ace',
help='3-letter language code, e.g. Ger (defaults to Ace)')
parser.add_argument('--lang-out',
type=str, action='store', dest='lang_out',
help='3-letter language code, e.g. Ger (defaults to Ace)')
parser.add_argument('-c', '--cat',
type=str, action='store', dest='cat',
default='ACEText',
help='start category (defaults to ACEText)')
parser.add_argument('-v', '--version', action='version', version='%(prog)s v0.1')
args = parser.parse_args()
if args.lang_out is None:
args.lang_out = ""
else:
args.lang_out = args.lang_out.replace(' ', ',')
process_lines(args.lang_in, args.lang_out, args.cat)
| 26.759259 | 96 | 0.694118 | 225 | 1,445 | 4.302222 | 0.368889 | 0.094008 | 0.051653 | 0.067149 | 0.35124 | 0.311983 | 0.258264 | 0.258264 | 0.119835 | 0.119835 | 0 | 0.009531 | 0.12872 | 1,445 | 53 | 97 | 27.264151 | 0.759333 | 0.152941 | 0 | 0.068966 | 0 | 0 | 0.268092 | 0 | 0 | 0 | 0 | 0.018868 | 0 | 0 | null | null | 0 | 0.068966 | null | null | 0.034483 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
38b1127b810f3f73f3e27b725954a3fabe02d8f7 | 202 | py | Python | python/testData/console/indent14.py | jnthn/intellij-community | 8fa7c8a3ace62400c838e0d5926a7be106aa8557 | [
"Apache-2.0"
] | 2 | 2018-12-29T09:53:39.000Z | 2018-12-29T09:53:42.000Z | python/testData/console/indent14.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 173 | 2018-07-05T13:59:39.000Z | 2018-08-09T01:12:03.000Z | python/testData/console/indent14.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 2 | 2020-03-15T08:57:37.000Z | 2020-04-07T04:48:14.000Z | print 'One, two. How are you?\
Three, four. Who\'s at the door?\
Five, six. My name is Fix.\
Seven, eght. Sorry, I\'m late.\
Nine, ten. Say it again.' | 40.4 | 45 | 0.480198 | 30 | 202 | 3.233333 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.391089 | 202 | 5 | 46 | 40.4 | 0.788618 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.2 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
38bbf9af68e9962a9a37eb0f715c948609ecd5da | 2,661 | py | Python | api/config.py | mindsolve/pySymProxy | 81d3a1760dd4b4d7ba4bcb2c41a619daf6b011cc | [
"MIT"
] | 27 | 2017-12-07T12:22:32.000Z | 2022-01-24T06:52:37.000Z | api/config.py | alastorid/pySymProxy | a696ac15a0a468f6ff3ad6fe4591b435656752c5 | [
"MIT"
] | 3 | 2019-07-31T08:05:48.000Z | 2021-04-20T13:33:42.000Z | api/config.py | alastorid/pySymProxy | a696ac15a0a468f6ff3ad6fe4591b435656752c5 | [
"MIT"
] | 8 | 2019-03-06T12:38:23.000Z | 2021-07-28T10:55:37.000Z | import logging
import logging.config
import logging.handlers
import json
import os
def findConfigFile(candidates):
for location in candidates:
if os.path.isfile(location):
return location
return candidates[-1]
def findConfigValue(rootDict, name, required = False, default = None):
curElement = rootDict
elements = name.split(".")
for element in elements:
curElement = curElement.get(element)
if (curElement == None):
break
if (curElement == None):
if (required):
raise Exception("Configuration value missing: " + name)
curElement = default
return curElement
class Config:
def __init__(self, configFile):
# Load configuration information
self._configFile = configFile
with open(configFile) as data_file:
self._configData = json.load(data_file)
logging.config.dictConfig(self.loggingConfig())
def configFile(self):
return self._configFile
def name(self):
return self.findConfigValue("identity.name")
def host(self):
return self.findConfigValue("identity.host")
def administrator(self):
return self.findConfigValue("identity.administrator")
def sympath(self):
return self.findConfigValue("identity.default_sympath")
def servers(self):
return self.findConfigValue("servers")
def cacheLocation(self):
return self.findConfigValue("general.cacheLocation")
def blacklist(self):
return self.findConfigValue("general.blacklist")
def loggingConfig(self):
return self.findConfigValue("logging", required=False, default={})
def extractLogFiles(self, logger, logfiles):
for handler in logger.handlers:
if isinstance(handler, logging.FileHandler):
logfiles.append(handler.baseFilename)
if isinstance(handler, logging.handlers.RotatingFileHandler):
for x in range(0, handler.backupCount):
logfiles.append(handler.baseFilename + "." + str(x))
def logfiles(self):
logfiles = []
for loggerName in logging.Logger.manager.loggerDict:
logger = logging.getLogger(loggerName)
self.extractLogFiles(logger, logfiles)
self.extractLogFiles(logger.root, logfiles)
logfiles = list(set(logfiles))
logfiles = [f for f in logfiles if os.path.exists(f)]
logfiles.sort()
return logfiles
def findConfigValue(self, name, required=True, default=None):
return findConfigValue(self._configData, name, required, default)
| 30.238636 | 77 | 0.654265 | 266 | 2,661 | 6.503759 | 0.308271 | 0.052023 | 0.072832 | 0.134104 | 0.127168 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001006 | 0.252537 | 2,661 | 87 | 78 | 30.586207 | 0.868778 | 0.011274 | 0 | 0.030769 | 0 | 0 | 0.059003 | 0.025504 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.076923 | 0.153846 | 0.538462 | 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 | 0 | 0 | 0 | 2 |
38cc696f5a58cce5eb3d2d36636d510496d1e270 | 660 | py | Python | test/pressure/test_hydrostatic.py | antineutrino2/pyGeoPressure | d28d6d0672e1abdb57ef97d7285ec68fcdfe8c73 | [
"MIT"
] | 53 | 2017-11-22T09:00:43.000Z | 2022-03-20T03:30:58.000Z | test/pressure/test_hydrostatic.py | linwang741/pyGeoPressure | 862d446c04e09dc347ac0a6e710c714cd3573266 | [
"MIT"
] | 16 | 2017-12-02T06:11:03.000Z | 2022-02-09T03:02:05.000Z | test/pressure/test_hydrostatic.py | linwang741/pyGeoPressure | 862d446c04e09dc347ac0a6e710c714cd3573266 | [
"MIT"
] | 35 | 2017-11-01T11:38:33.000Z | 2022-03-21T02:39:57.000Z | # -*- coding: utf-8 -*-
"""
Created on Nov. 9th 2017
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import numpy as np
import pygeopressure as ppp
def test_hydrostatic(depth):
assert (ppp.hydrostatic_pressure(depth) == \
np.array([0., 0.00980665, 0.0196133, 0.02941995, 0.0392266,
0.04903325, 0.0588399, 0.06864655, 0.0784532,
0.08825985])).all()
assert (np.round(ppp.hydrostatic_trace(depth), 6) == \
np.array([0., 0.009898, 0.019796, 0.029694, 0.039592, 0.04949,
0.059388, 0.069286, 0.079184, 0.089082])).all()
| 33 | 70 | 0.604545 | 87 | 660 | 4.471264 | 0.597701 | 0.071979 | 0.041131 | 0.046272 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.297787 | 0.24697 | 660 | 19 | 71 | 34.736842 | 0.484909 | 0.071212 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.083333 | false | 0 | 0.25 | 0 | 0.333333 | 0.083333 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
38d32f21f9f3751d1ec17ed5372568755353a89a | 477 | py | Python | elpa-26.1/elpy-20190406.1455/elpy/tests/test_auto_pep8.py | heyangcn/emacs.d | d0acdd09127b937f3f4a16b89ea6f4bb11e104a7 | [
"BSD-2-Clause"
] | 11 | 2018-01-12T02:13:04.000Z | 2021-05-14T20:47:47.000Z | elpa/elpy-20180916.839/elpy/tests/test_auto_pep8.py | jueqingsizhe66/ranEmacs.d | d1d2684857feeaf505a3cddcf044f7a60d10d1a4 | [
"Unlicense"
] | 1 | 2020-03-24T12:50:29.000Z | 2020-03-24T12:51:11.000Z | elpa/elpy-20180916.839/elpy/tests/test_auto_pep8.py | jueqingsizhe66/ranEmacs.d | d1d2684857feeaf505a3cddcf044f7a60d10d1a4 | [
"Unlicense"
] | 1 | 2020-11-04T05:05:12.000Z | 2020-11-04T05:05:12.000Z | # coding: utf-8
"""Tests for the elpy.autopep8 module"""
import unittest
import os
from elpy import auto_pep8
from elpy.tests.support import BackendTestCase
class Autopep8TestCase(BackendTestCase):
def setUp(self):
if not auto_pep8.autopep8:
raise unittest.SkipTest
def test_fix_code(self):
code_block = 'x= 123\n'
new_block = auto_pep8.fix_code(code_block, os.getcwd())
self.assertEqual(new_block, 'x = 123\n')
| 21.681818 | 63 | 0.679245 | 65 | 477 | 4.830769 | 0.553846 | 0.076433 | 0.057325 | 0.063694 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03523 | 0.226415 | 477 | 21 | 64 | 22.714286 | 0.815718 | 0.102725 | 0 | 0 | 0 | 0 | 0.054502 | 0 | 0 | 0 | 0 | 0 | 0.083333 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.583333 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
38d4d1ab42d4a74f1d64f9c5639e4bffa8dd1f8e | 354 | py | Python | {{ cookiecutter.project_slug }}/{{ cookiecutter.service_name }}/main.py | churnikov/cookiecutter-python | 2be81a751896bce7874f63b546111d1faea02d59 | [
"MIT"
] | 2 | 2021-09-12T13:39:26.000Z | 2021-09-13T07:53:19.000Z | {{ cookiecutter.project_slug }}/{{ cookiecutter.service_name }}/main.py | churnikov/cookiecutter-python | 2be81a751896bce7874f63b546111d1faea02d59 | [
"MIT"
] | null | null | null | {{ cookiecutter.project_slug }}/{{ cookiecutter.service_name }}/main.py | churnikov/cookiecutter-python | 2be81a751896bce7874f63b546111d1faea02d59 | [
"MIT"
] | null | null | null | import sys
from loguru import logger
from .log import DevelopFormatter, JsonSink
from .settings import settings
logger.remove()
if settings.env == "development":
develop_fmt = DevelopFormatter(settings.component_name)
logger.add(sys.stdout, format=develop_fmt)
else:
json_sink = JsonSink(settings.component_name)
logger.add(json_sink)
| 23.6 | 59 | 0.776836 | 45 | 354 | 5.977778 | 0.511111 | 0.074349 | 0.156134 | 0.200743 | 0.223048 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138418 | 354 | 14 | 60 | 25.285714 | 0.881967 | 0 | 0 | 0 | 0 | 0 | 0.031073 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.363636 | 0 | 0.363636 | 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 | 0 | 0 | 0 | 2 |
38d649426d56dab0c1fcc6edf2343c6dca3ed069 | 4,644 | py | Python | dirbot/spiders/dmoz.py | lihongqiang/crawl-image-baidu | ab6008e7f40eac0e91eb7ed035c1773f1850925b | [
"Apache-2.0"
] | 1 | 2017-03-24T09:46:26.000Z | 2017-03-24T09:46:26.000Z | dirbot/spiders/dmoz.py | lihongqiang/crawl-image-baidu | ab6008e7f40eac0e91eb7ed035c1773f1850925b | [
"Apache-2.0"
] | 1 | 2017-03-24T08:51:17.000Z | 2017-03-24T08:51:17.000Z | dirbot/spiders/dmoz.py | lihongqiang/crawl-image-baidu | ab6008e7f40eac0e91eb7ed035c1773f1850925b | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python
# -*- coding: utf-8 -*-
from scrapy.spiders import Spider
import json
from dirbot.items import MyImage
from scrapy.crawler import Crawler
import sys
import urllib
# reload(sys)
# sys.setdefaultencoding('utf-8')
wordList = [ u"动物", u"狗", u"猫", u"熊", u"兔子", u"狮子", u"老虎", u"牛", u"马", u"长颈鹿", u"猴子", u"大象", u"鹿", u"大熊猫", u"小熊猫", u"刺猬", u"豹子", u"犀牛", u"考拉", u"大猩猩", u"驴", u"鼠", u"狐", u"狼", u"山羊", u"鹰", u"鸡", u"鸭子", u"天鹅", u"鹅", u"麻雀", u"燕子", u"鸵鸟", u"啄木鸟", u"鹦鹉", u"珊瑚", u"海星", u"水母", u"龟", u"鸭嘴兽", u"鲶鱼", u"鲨鱼", u"章鱼", u"鲟鱼", u"鲤鱼", u"海豚", u"蝴蝶", u"蜻蜓", u"蜗牛", u"蜜蜂", u"蚂蚁", u"水果", u"苹果", u"桃", u"葡萄", u"香蕉", u"菠萝", u"西瓜", u"柠檬", u"芒果", u"草莓", u"樱桃", u"枣", u"杏", u"橙", u"李子", u"石榴", u"弥猴桃", u"荔枝", u"桔子", u"柚子", u"青柠檬", u"山药", u"榴莲", u"山竹", u"毛丹", u"槟榔", u"龙眼", u"枇杷,欧查果", u"无花果", u"柿子", u"胡桃", u"榛子", u"油桃", u"桑椹", u"栗", u"醋粟", u"可可", u"越桔", u"黑莓", u"梨", u"杨桃", u"椰子", u"金桔", u"菠萝蜜", u"火龙果", u"番茄", u"哈密瓜", u"木瓜", u"杨梅", u"香瓜", u"山楂", u"车辆", u"自行车", u"摩托车", u"皮卡车", u"火车", u"坦克", u"拖拉机", u"小汽车", u"敞篷车", u"长途客车", u"双层巴士", u"普通货车", u"半挂牵引车", u"厢式货车", u"罐式货车", u"三轮摩托车", u"救护车", u"警车", u"消防车", u"洒水车", u"环卫车", u"拖拉机", u"越野汽车", u"火车", u"火箭", u"坦克", u"客机", u"飞行汽车", u"战斗机", u"滑翔机", u"侦察机", u"预警机", u"武装直升机", u"民用直升机", u"轰炸机", u"小船", u"客轮", u"货轮", u"快艇", u"帆船", u"航空母舰", u"潜艇", u"气垫船", u"平衡车", u"电动自行车", u"吊车", u"叉车", u"房车", u"吉普车", u"卡丁车", u"赛车", u"电子装置", u"笔记本电脑", u"电脑显示器", u"键盘", u"电话", u"照相机", u"时钟", u"电视", u"手机", u"遥控器", u"充电器", u"数据线", u"电话机", u"对讲机", u"闪存卡", u"镜头", u"手机电池", u"笔记本电池", u"手机充电器", u"笔记本电源适配器", u"硬盘", u"摄像头", u"音响", u"有线耳机", u"蓝牙耳机", u"打印机", u"投影机", u"路由器", u"CPU", u"GPU", u"交换机", u"冰箱", u"洗衣机", u"空调", u"微波炉", u"电磁炉", u"浴霸", u"台灯", u"电话卡", u"U盘", u"MP3", u"MP4", u"平板", u"台式主机", u"台式机电源", u"主板", u"内存", u"LED屏", u"游戏手柄", u"点钞机", u"吸尘器", u"烟雾报警器"]
# wordList = [ u"动物"]
totalPage = 10
# label_num = 0
def getURL(pagenum, word):
return 'https://image.baidu.com/search/avatarjson?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1488547724906_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&ctd=1488547724907%5E00_1002X1024&rn=200&pn=' + str(pagenum) + '&word=' + word
def getWordList(file_path):
wordList = []
with open(file_path, "r") as f:
for line in f:
words = line.split("\n")
print words[0]
wordList.append(words[0])
return wordList
class DmozSpider(Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = []
# BASE_PATH = 'D:/lhq/openimages/baidusearch'
word = 'cat'
# word = settings['IMAGES_LABEL']
# myset = Settings()
wordList = getWordList("./labels")
for word in wordList:
# print myset.get('IMAGES_STORE')
# print Settings['IMAGES_STORE']
# Settings['IMAGES_STORE'] = BASE_PATH + "/" + str(i)
# settings.set('IMAGES_STORE', BASE_PATH + "/" + word)
for pagenum in range(int(totalPage)):
start_urls.append(getURL(pagenum*60, word))
# label_num += 1
# def parse(self, response):
# """
# The lines below is a spider contract. For more info see:
# http://doc.scrapy.org/en/latest/topics/contracts.html
#
# @url http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/
# @scrapes name
# """
#
# # item = Website()
# # title = response.xpath('/html/head/title/text()').extract()
# # redictTitle = response.xpath('//td[contains(@class, "line-content")]/text()').extract()
# # item['title'] = title
# # item['redictTitle'] = redictTitle
# # for t in title:
# # t = t.strip('\n\t')
# # if t != "":
# # item['title'] = t
# # break
# # print item['title']
# # print item['redictTitle']
# # yield item
# print 'output'
# print response.body
# def from_crawler(cls, crawler, *args, **kwargs):
# settings = crawler.settings
# if settings['IMAGES_LABEL']:
# print "log is enabled!"
# word = settings['IMAGES_LABEL']
# print word
def getName(self, word):
ret_word = word
ret_word = urllib.unquote(word).decode('utf-8')
return ret_word
def parse(self, response):
sites = json.loads(response.body_as_unicode())
label = str(response.url).strip().split("word=")[-1]
for site in sites['imgs']:
image = MyImage()
image['image_urls'] = [site['objURL']]
image['image_label'] = self.getName(label)
yield image
| 47.387755 | 1,554 | 0.53919 | 787 | 4,644 | 3.147395 | 0.480305 | 0.02826 | 0.023012 | 0.018571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020787 | 0.223084 | 4,644 | 97 | 1,555 | 47.876289 | 0.665743 | 0.286822 | 0 | 0 | 0 | 0.025641 | 0.258451 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.153846 | null | null | 0.025641 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c7fb1ae22d8a5f6af7cffe2226aa7f825eaecc89 | 298 | py | Python | polls/models.py | sergeymuravko/django_2 | 88697745a2e94e4ee498dbef1e5c8a5e8fb2c585 | [
"MIT"
] | null | null | null | polls/models.py | sergeymuravko/django_2 | 88697745a2e94e4ee498dbef1e5c8a5e8fb2c585 | [
"MIT"
] | null | null | null | polls/models.py | sergeymuravko/django_2 | 88697745a2e94e4ee498dbef1e5c8a5e8fb2c585 | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
class Poll(models.Model):
name = models.CharField(max_length=60, null=True, blank=True)
def __str__(self):
return '{}'.format(self.name)
class Meta:
verbose_name = "Poll"
verbose_name_plural = "Polls"
| 19.866667 | 65 | 0.654362 | 39 | 298 | 4.794872 | 0.717949 | 0.117647 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008734 | 0.231544 | 298 | 14 | 66 | 21.285714 | 0.80786 | 0.080537 | 0 | 0 | 0 | 0 | 0.040441 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.125 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
2a09f1854ee23e5cd5c17cfee8005f7ee1c66924 | 367 | py | Python | pytorch-SAC/utils.py | Fable67/Soft-Actor-Critic-Pytorch | 034c5cc37904f568773cdf3c25caf1a5d28a6cee | [
"MIT"
] | 4 | 2019-05-08T23:18:26.000Z | 2019-09-05T19:59:47.000Z | pytorch-SAC/utils.py | Fable67/Soft-Actor-Critic-Pytorch | 034c5cc37904f568773cdf3c25caf1a5d28a6cee | [
"MIT"
] | null | null | null | pytorch-SAC/utils.py | Fable67/Soft-Actor-Critic-Pytorch | 034c5cc37904f568773cdf3c25caf1a5d28a6cee | [
"MIT"
] | 1 | 2022-01-19T06:47:56.000Z | 2022-01-19T06:47:56.000Z | import torch
def hard_copy(targ_net, net):
for p_target, p in zip(targ_net.parameters(), net.parameters()):
p_target.data.copy_(p.data)
return targ_net
def soft_copy(targ_net, net, tau):
for target_p, p in zip(targ_net.parameters(), net.parameters()):
target_p.data.copy_(target_p.data * (1. - tau) + p.data * tau)
return targ_net
| 26.214286 | 70 | 0.673025 | 61 | 367 | 3.803279 | 0.295082 | 0.181034 | 0.094828 | 0.12069 | 0.310345 | 0.310345 | 0.310345 | 0.310345 | 0 | 0 | 0 | 0.003378 | 0.19346 | 367 | 13 | 71 | 28.230769 | 0.780405 | 0 | 0 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 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 | 0 | 1 | 0 | 0 | 2 |
2a0fd1acdf8877425b19956345a7dc818f10f00d | 595 | py | Python | tests/beta_tests/test_no_duplicates_here.py | the-zebulan/CodeWars | 1eafd1247d60955a5dfb63e4882e8ce86019f43a | [
"MIT"
] | 40 | 2016-03-09T12:26:20.000Z | 2022-03-23T08:44:51.000Z | tests/beta_tests/test_no_duplicates_here.py | akalynych/CodeWars | 1eafd1247d60955a5dfb63e4882e8ce86019f43a | [
"MIT"
] | null | null | null | tests/beta_tests/test_no_duplicates_here.py | akalynych/CodeWars | 1eafd1247d60955a5dfb63e4882e8ce86019f43a | [
"MIT"
] | 36 | 2016-11-07T19:59:58.000Z | 2022-03-31T11:18:27.000Z | import unittest
from katas.beta.no_duplicates_here import list_de_dup
class ListDeDuplicateTestCase(unittest.TestCase):
def test_equals(self):
self.assertEqual(list_de_dup(['g', 3, 'a', 'a']), [3, 'a', 'g'])
def test_equals_2(self):
self.assertEqual(list_de_dup([1, 2, 3, 4, 1, 2, 3, 4]), [1, 2, 3, 4])
def test_equals_3(self):
self.assertEqual(list_de_dup([
'code', 'wars', 'ain\'t', None, None, 'code', 'wars', 'ain\'t',
'the', 'same', 'as', 'the', 'rest']),
['ain\'t', 'as', 'code', 'rest', 'same', 'the', 'wars'])
| 33.055556 | 77 | 0.561345 | 87 | 595 | 3.666667 | 0.390805 | 0.075235 | 0.112853 | 0.216301 | 0.30094 | 0.30094 | 0.037618 | 0.037618 | 0 | 0 | 0 | 0.034483 | 0.220168 | 595 | 17 | 78 | 35 | 0.653017 | 0 | 0 | 0 | 0 | 0 | 0.114286 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.166667 | 0 | 0.5 | 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 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.