code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
class DeleteSTFT(object): <NEW_LINE> <INDENT> def __call__(self, data): <NEW_LINE> <INDENT> del data["stft"] <NEW_LINE> return data
Pytorch doesn't like complex numbers, use this transform to remove STFT after computing the mel spectrogram.
62598fa22c8b7c6e89bd3645
class Conf: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.debug = False <NEW_LINE> self.ddebug = False <NEW_LINE> self.config = None
Class which contains runtime variables
62598fa27cff6e4e811b58a6
class TestNotImplementedIsPropagated(object): <NEW_LINE> <INDENT> def test_not_implemented_is_propagated(self): <NEW_LINE> <INDENT> C = cmp_using(eq=lambda a, b: NotImplemented if a == 1 else a == b) <NEW_LINE> assert C(2) == C(2) <NEW_LINE> assert C(1) != C(1)
Test related to functions that return NotImplemented.
62598fa2851cf427c66b8148
class DescribeTaskStatusResponse(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.TaskResult = None <NEW_LINE> self.TaskType = None <NEW_LINE> self.RequestId = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> self.TaskResult = params.get("TaskResult") <NEW_LINE> self.TaskType = params.get("TaskType") <NEW_LINE> self.RequestId = params.get("RequestId")
DescribeTaskStatus返回参数结构体
62598fa2009cb60464d013a5
class UndoAction(AbstractCommandStackAction): <NEW_LINE> <INDENT> def perform(self, event): <NEW_LINE> <INDENT> self.undo_manager.undo() <NEW_LINE> <DEDENT> def _update_action(self): <NEW_LINE> <INDENT> name = self.undo_manager.undo_name <NEW_LINE> if name: <NEW_LINE> <INDENT> name = "&Undo " + name <NEW_LINE> self.enabled = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = "&Undo" <NEW_LINE> self.enabled = False <NEW_LINE> <DEDENT> self.name = name
An action that undos the last command of the active command stack.
62598fa2d7e4931a7ef3bf1a
class CompressionType(object): <NEW_LINE> <INDENT> NONE = 0 <NEW_LINE> GZIP = 1 <NEW_LINE> SNAPPY = 2
Enum for the various compressions supported. :cvar NONE: Indicates no compression in use :cvar GZIP: Indicates gzip compression in use :cvar SNAPPY: Indicates snappy compression in use
62598fa2442bda511e95c2db
class CryptoKeyAuditRule(AuditRule): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def __new__(self,identity,cryptoKeyRights,flags): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> AccessMask=property(lambda self: object(),lambda self,v: None,lambda self: None) <NEW_LINE> CryptoKeyRights=property(lambda self: object(),lambda self,v: None,lambda self: None)
Represents an audit rule for a cryptographic key. An audit rule represents a combination of a user's identity and an access mask. An audit rule also contains information about the how the rule is inherited by child objects,how that inheritance is propagated,and for what conditions it is audited. CryptoKeyAuditRule(identity: IdentityReference,cryptoKeyRights: CryptoKeyRights,flags: AuditFlags) CryptoKeyAuditRule(identity: str,cryptoKeyRights: CryptoKeyRights,flags: AuditFlags)
62598fa27b25080760ed732a
class Recipe(models.Model): <NEW_LINE> <INDENT> user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, ) <NEW_LINE> title = models.CharField(max_length=255) <NEW_LINE> time_minutes = models.IntegerField() <NEW_LINE> price = models.DecimalField(max_digits=6, decimal_places=2) <NEW_LINE> link = models.CharField(max_length=255, blank=True) <NEW_LINE> ingredients = models.ManyToManyField('Ingredient') <NEW_LINE> tags = models.ManyToManyField('Tag') <NEW_LINE> image = models.ImageField(null=True, upload_to=recipe_image_file_path) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return self.title
Ingredients to be used for a recipe
62598fa285dfad0860cbf9b4
class RawAsyncServer(RawServer): <NEW_LINE> <INDENT> pool = pool.Pool() <NEW_LINE> def handle_handler(self, handler): <NEW_LINE> <INDENT> self.pool.start(Greenlet(handler.run))
Prefered server instead of RawServer. Async server using :class:`gevent.Greenlet` in a :class:`gevent.pool` to allow asynchronous calls. This will ensure you are not loosing data because the handler is too long.
62598fa276e4537e8c3ef42c
class Artifact(SkeleYaml): <NEW_LINE> <INDENT> VERSIONED_NAME = "{filename}_v{version}.{ext}" <NEW_LINE> SINGULAR_NAME = "{filename}.{ext}" <NEW_LINE> schema = Schema({ 'name': And(str, error="Artifact 'name' must be a String"), 'file': And(str, error="Artifact 'file' must be a String"), Optional('singular'): And(bool, error="Artifact 'singular' must be a Boolean"), }, ignore_extra_keys=True) <NEW_LINE> name = None <NEW_LINE> file = None <NEW_LINE> singular = None <NEW_LINE> def __init__(self, name, file, singular=False): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.file = file <NEW_LINE> self.singular = singular <NEW_LINE> <DEDENT> def getVersionedName(self, version): <NEW_LINE> <INDENT> ext = self.file.split(".")[1] <NEW_LINE> ver_name = None <NEW_LINE> if (self.singular): <NEW_LINE> <INDENT> ver_name = self.SINGULAR_NAME.format(filename=self.name, ext=ext) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ver_name = self.VERSIONED_NAME.format(filename=self.name, version=version, ext=ext) <NEW_LINE> <DEDENT> return ver_name
Artifact Class Object contained within a list of the artifactory configuration in order to specify the artifact files and artifact names
62598fa20c0af96317c56202
class RequestParams(object): <NEW_LINE> <INDENT> params = None <NEW_LINE> def __init__(self, param=None): <NEW_LINE> <INDENT> self.delimiter = ',' <NEW_LINE> if param is None: <NEW_LINE> <INDENT> self.params = NoCaseMultiDict() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.params = NoCaseMultiDict(param) <NEW_LINE> <DEDENT> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.query_string <NEW_LINE> <DEDENT> def get(self, key, default=None, type_func=None): <NEW_LINE> <INDENT> return self.params.get(key, default, type_func) <NEW_LINE> <DEDENT> def set(self, key, value, append=False, unpack=False): <NEW_LINE> <INDENT> self.params.set(key, value, append=append, unpack=unpack) <NEW_LINE> <DEDENT> def update(self, mapping=(), append=False): <NEW_LINE> <INDENT> self.params.update(mapping, append=append) <NEW_LINE> <DEDENT> def __getattr__(self, name): <NEW_LINE> <INDENT> if name in self: <NEW_LINE> <INDENT> return self[name] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise AttributeError("'%s' object has no attribute '%s" % (self.__class__.__name__, name)) <NEW_LINE> <DEDENT> <DEDENT> def __getitem__(self, key): <NEW_LINE> <INDENT> return self.delimiter.join(map(str, self.params.get_all(key))) <NEW_LINE> <DEDENT> def __setitem__(self, key, value): <NEW_LINE> <INDENT> self.set(key, value) <NEW_LINE> <DEDENT> def __delitem__(self, key): <NEW_LINE> <INDENT> if key in self: <NEW_LINE> <INDENT> del self.params[key] <NEW_LINE> <DEDENT> <DEDENT> def iteritems(self): <NEW_LINE> <INDENT> for key, values in self.params.iteritems(): <NEW_LINE> <INDENT> yield key, self.delimiter.join((str(x) for x in values)) <NEW_LINE> <DEDENT> <DEDENT> def __contains__(self, key): <NEW_LINE> <INDENT> return self.params and key in self.params <NEW_LINE> <DEDENT> def copy(self): <NEW_LINE> <INDENT> return self.__class__(self.params) <NEW_LINE> <DEDENT> @property <NEW_LINE> def query_string(self): <NEW_LINE> <INDENT> kv_pairs = [] <NEW_LINE> for key, values in self.params.iteritems(): <NEW_LINE> <INDENT> value = ','.join(str(v) for v in values) <NEW_LINE> kv_pairs.append(key + '=' + urllib.quote_plus(value, safe=',')) <NEW_LINE> <DEDENT> return '&'.join(kv_pairs) <NEW_LINE> <DEDENT> def with_defaults(self, defaults): <NEW_LINE> <INDENT> new = self.copy() <NEW_LINE> for key, value in defaults.params.iteritems(): <NEW_LINE> <INDENT> if value != [None]: <NEW_LINE> <INDENT> new.set(key, value, unpack=True) <NEW_LINE> <DEDENT> <DEDENT> return new
This class represents key-value request parameters. It allows case-insensitive access to all keys. Multiple values for a single key will be concatenated (eg. to ``layers=foo&layers=bar`` becomes ``layers: foo,bar``). All values can be accessed as a property. :param param: A dict or ``NoCaseMultiDict``.
62598fa23eb6a72ae038a4c4
class StagingCallback(Callback): <NEW_LINE> <INDENT> def __init__(self, stage_op, unstage_op, nr_stage): <NEW_LINE> <INDENT> self.nr_stage = nr_stage <NEW_LINE> self.stage_op = stage_op <NEW_LINE> self.fetches = tf.train.SessionRunArgs( fetches=[stage_op, unstage_op]) <NEW_LINE> <DEDENT> def _before_train(self): <NEW_LINE> <INDENT> logger.info("Pre-filling staging area ...") <NEW_LINE> for k in range(self.nr_stage): <NEW_LINE> <INDENT> self.stage_op.run() <NEW_LINE> <DEDENT> <DEDENT> def _before_run(self, ctx): <NEW_LINE> <INDENT> return self.fetches
A callback registered by this input source, to make sure stage/unstage is run at each step.
62598fa299cbb53fe6830d54
class Replacer(object): <NEW_LINE> <INDENT> def __init__(self, original_expr): <NEW_LINE> <INDENT> self.original_expr = original_expr <NEW_LINE> self.escaped_map = {} <NEW_LINE> <DEDENT> def __call__(self, match): <NEW_LINE> <INDENT> meter_name = match.group(1) <NEW_LINE> escaped_name = self.escape(meter_name) <NEW_LINE> self.escaped_map[meter_name] = escaped_name <NEW_LINE> if (match.end(0) == len(self.original_expr) or self.original_expr[match.end(0)] != '.'): <NEW_LINE> <INDENT> escaped_name += '.volume' <NEW_LINE> <DEDENT> return escaped_name <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def escape(name): <NEW_LINE> <INDENT> has_dot = '.' in name <NEW_LINE> if has_dot: <NEW_LINE> <INDENT> name = name.replace('.', '_') <NEW_LINE> <DEDENT> if has_dot or name.endswith('ESC') or name in keyword.kwlist: <NEW_LINE> <INDENT> name = "_" + name + '_ESC' <NEW_LINE> <DEDENT> return name
Replaces matched meter names with escaped names. If the meter name is not followed by parameter access in the expression, it defaults to accessing the 'volume' parameter.
62598fa20a50d4780f70525c
class Client(models.Model): <NEW_LINE> <INDENT> name = models.CharField(max_length=100, help_text="Name of client to display") <NEW_LINE> slug = models.CharField(max_length=50, help_text="Used in URL", unique=True) <NEW_LINE> url = models.URLField(blank=True, help_text="URL to send viewer to") <NEW_LINE> class Meta: <NEW_LINE> <INDENT> ordering = ['name'] <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.name <NEW_LINE> <DEDENT> def get_absolute_url(self): <NEW_LINE> <INDENT> return '/portfolio/client/' + self.slug
Database Object Model for storing the clients that the projects where done for
62598fa291af0d3eaad39c8d
class FeatureDragger(FeaturePicker): <NEW_LINE> <INDENT> feature_dragged = pyqtSignal(int, QgsPointXY) <NEW_LINE> drag_cursor = QCursor(Qt.DragMoveCursor) <NEW_LINE> def __init__(self, ui_element: QWidget, layers: List[QgsVectorLayer] = [], canvas: QgsMapCanvas = None, target_epsg: int = 25832): <NEW_LINE> <INDENT> super().__init__(ui_element, layers=layers, canvas=canvas) <NEW_LINE> self._marker = None <NEW_LINE> self._picked_feature = None <NEW_LINE> self._dragging = False <NEW_LINE> self.target_crs = QgsCoordinateReferenceSystem(target_epsg) <NEW_LINE> <DEDENT> def reset(self): <NEW_LINE> <INDENT> self.remove_marker() <NEW_LINE> self._picked_feature = None <NEW_LINE> <DEDENT> def remove_marker(self): <NEW_LINE> <INDENT> if not self._marker: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.canvas.scene().removeItem(self._marker) <NEW_LINE> self._marker = None <NEW_LINE> <DEDENT> def canvasPressEvent(self, e): <NEW_LINE> <INDENT> if self._picked_feature is None: <NEW_LINE> <INDENT> features = QgsMapToolIdentify(self.canvas).identify( e.pos().x(), e.pos().y(), self._layers, QgsMapToolIdentify.TopDownStopAtFirst) <NEW_LINE> if len(features) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> feature = features[0].mFeature <NEW_LINE> self._picked_feature = feature.id() <NEW_LINE> <DEDENT> self._dragging = True <NEW_LINE> self.canvas.setCursor(self.drag_cursor) <NEW_LINE> if not self._marker: <NEW_LINE> <INDENT> color = QColor(0, 0, 255) <NEW_LINE> color.setAlpha(100) <NEW_LINE> self._marker = QgsVertexMarker(self.canvas) <NEW_LINE> self._marker.setColor(color) <NEW_LINE> self._marker.setIconSize(10) <NEW_LINE> self._marker.setIconType(QgsVertexMarker.ICON_CIRCLE) <NEW_LINE> self._marker.setPenWidth(10) <NEW_LINE> <DEDENT> point = self.toMapCoordinates(e.pos()) <NEW_LINE> self._marker.setCenter(point) <NEW_LINE> <DEDENT> def canvasMoveEvent(self, e): <NEW_LINE> <INDENT> if not self._marker or not self._dragging: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> point = self.toMapCoordinates(e.pos()) <NEW_LINE> self._marker.setCenter(point) <NEW_LINE> <DEDENT> def canvasReleaseEvent(self, mouseEvent): <NEW_LINE> <INDENT> self._dragging = False <NEW_LINE> if self._picked_feature is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.canvas.setCursor(self.cursor) <NEW_LINE> point = self.toMapCoordinates(self._marker.pos().toPoint()) <NEW_LINE> self.feature_dragged.emit(self._picked_feature, self.transform_from_map(point))
tool for moving features on the map canvas with drag & drop, does not change the geometry of the dragged feature but draws a marker at the new position and emits the geometry Attributes ---------- feature_dragged : pyqtSignal emitted when a feature is dragged or clicked on the map canvas, (feature id, release position) drag_cursor : QCursor the appearance of the cursor while dragging a feature
62598fa2f548e778e596b42f
class Model(object): <NEW_LINE> <INDENT> def request(self, headers, path_params, query_params, body_value): <NEW_LINE> <INDENT> _abstract() <NEW_LINE> <DEDENT> def response(self, resp, content): <NEW_LINE> <INDENT> _abstract()
Model base class. All Model classes should implement this interface. The Model serializes and de-serializes between a wire format such as JSON and a Python object representation.
62598fa23d592f4c4edbad4e
class FaultProvider: <NEW_LINE> <INDENT> def __init__(self, worklist_values): <NEW_LINE> <INDENT> self._worklist_values = worklist_values <NEW_LINE> available_languages = { "chineseEnabled": '也池馳弛水马弓土人女', "russianEnabled": 'ДРЛИПЦЗГБЖ', "greekEnabled": 'ΑαΒβΓγΔδΕεΖζΗηΘθΙιψΩω', "japaneseEnabled": '日一大二目五後.女かたまやたば', "koreanEnabled": 'ㄱㄴㄷㄹㅇㅈㅑㅓㅕㅗㅛㅔㅖㅚㅿㆆㆍ' } <NEW_LINE> self.allowedlanguages = [ 'æÆøØåÅßäöüÄÖÜ' ] <NEW_LINE> for key in available_languages.keys(): <NEW_LINE> <INDENT> if self._worklist_values[key]: <NEW_LINE> <INDENT> self.allowedlanguages.append(available_languages[key]) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def _get_random_string_length(self, max_len): <NEW_LINE> <INDENT> r = random.uniform(0.0, 100.0) <NEW_LINE> if self._worklist_values["oversizedStringsEnabled"]: <NEW_LINE> <INDENT> if (r < self._worklist_values["likelihoodOfLongString"]): <NEW_LINE> <INDENT> return random.randrange(max_len+1, max_len+10) <NEW_LINE> <DEDENT> <DEDENT> if self._worklist_values["emptyStringsEnabled"]: <NEW_LINE> <INDENT> if (r > self._worklist_values["likelihoodOfLongString"] and r < (self._worklist_values["likelihoodOfLongString"] + self._worklist_values["likelihoodOfEmptyString"])): <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> <DEDENT> return max_len <NEW_LINE> <DEDENT> def _return_None_string(self): <NEW_LINE> <INDENT> if (self._worklist_values["noneStringsEnabled"]): <NEW_LINE> <INDENT> r = random.uniform(0.0, 100.0) <NEW_LINE> if (r <= self._worklist_values["likelihoodOfNoneString"]): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False <NEW_LINE> <DEDENT> def _sleep_random(self): <NEW_LINE> <INDENT> if self._worklist_values["delayEnabled"]: <NEW_LINE> <INDENT> r = random.uniform(0.0, 100.0) <NEW_LINE> if (r <= self._worklist_values["likelihoodOfDelay"]): <NEW_LINE> <INDENT> time.sleep(self._worklist_values["delayTime"]) <NEW_LINE> <DEDENT> <DEDENT> return 0 <NEW_LINE> <DEDENT> def _get_random_language_string(self): <NEW_LINE> <INDENT> r = random.uniform(0.0, 100.0) <NEW_LINE> if (r <= self._worklist_values["likelihoodOfLanguage"]): <NEW_LINE> <INDENT> return self.allowedlanguages[random.randint(0, (len(self.allowedlanguages) - 1))] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.allowedlanguages[0]
Gives faulty input to exam-objects
62598fa2498bea3a75a579a3
class Robot(object): <NEW_LINE> <INDENT> speed = 0 <NEW_LINE> direction = 0 <NEW_LINE> position = Position(0, 0) <NEW_LINE> room = None <NEW_LINE> def __init__(self, room, speed): <NEW_LINE> <INDENT> self.speed = speed <NEW_LINE> self.direction = random.randint(0, 360) <NEW_LINE> self.position = room.getRandomPosition() <NEW_LINE> self.room = room <NEW_LINE> self.room.cleanTileAtPosition(self.position) <NEW_LINE> <DEDENT> def getRobotPosition(self): <NEW_LINE> <INDENT> return self.position <NEW_LINE> <DEDENT> def getRobotDirection(self): <NEW_LINE> <INDENT> return self.direction <NEW_LINE> <DEDENT> def setRobotPosition(self, position): <NEW_LINE> <INDENT> self.position = position <NEW_LINE> <DEDENT> def setRobotDirection(self, direction): <NEW_LINE> <INDENT> self.direction = direction <NEW_LINE> <DEDENT> def updatePositionAndClean(self): <NEW_LINE> <INDENT> raise NotImplementedError
Represents a robot cleaning a particular room. At all times the robot has a particular position and direction in the room. The robot also has a fixed speed. Subclasses of Robot should provide movement strategies by implementing updatePositionAndClean(), which simulates a single time-step.
62598fa2d268445f26639ac3
class TopFrameView(BaseInsertView): <NEW_LINE> <INDENT> def get_top_frame(self, wb_url, wb_prefix, host_prefix, env, frame_mod, replay_mod, coll='', extra_params=None): <NEW_LINE> <INDENT> embed_url = wb_url.to_str(mod=replay_mod) <NEW_LINE> if wb_url.timestamp: <NEW_LINE> <INDENT> timestamp = wb_url.timestamp <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> timestamp = timestamp_now() <NEW_LINE> <DEDENT> is_proxy = 'wsgiprox.proxy_host' in env <NEW_LINE> params = {'host_prefix': host_prefix, 'wb_prefix': wb_prefix, 'wb_url': wb_url, 'coll': coll, 'options': {'frame_mod': frame_mod, 'replay_mod': replay_mod}, 'embed_url': embed_url, 'is_proxy': is_proxy, 'timestamp': timestamp, 'url': wb_url.get_url() } <NEW_LINE> if extra_params: <NEW_LINE> <INDENT> params.update(extra_params) <NEW_LINE> <DEDENT> if self.banner_view: <NEW_LINE> <INDENT> banner_html = self.banner_view.render_to_string(env, **params) <NEW_LINE> params['banner_html'] = banner_html <NEW_LINE> <DEDENT> return self.render_to_string(env, **params)
The template view class associated with rendering the replay iframe
62598fa22ae34c7f260aaf61
class AlarmNum(db.Model): <NEW_LINE> <INDENT> __tablename__ = 'alarm_num' <NEW_LINE> uuid = db.Column(db.BigInteger, primary_key=True) <NEW_LINE> org_id = db.Column(db.BIGINT, default=None) <NEW_LINE> row_datetime = db.Column(db.DateTime, default=None) <NEW_LINE> alarm_num = db.Column(db.Integer, default=None)
报警次数
62598fa2aad79263cf42e660
class MainServer(): <NEW_LINE> <INDENT> def __init__(self, host, commandPort, dataPort, userPort, infoPort): <NEW_LINE> <INDENT> self.host = host <NEW_LINE> self.portC = commandPort <NEW_LINE> self.portD = dataPort <NEW_LINE> self.portU = userPort <NEW_LINE> self.portI = infoPort <NEW_LINE> self.threads = [] <NEW_LINE> <DEDENT> def start(self): <NEW_LINE> <INDENT> self.DSaver = DataSaver(maindir=getcwd()) <NEW_LINE> self.DThread = DatarcvThread((self.host, self.portD), self.DSaver, listenMax=1) <NEW_LINE> self.threads.append(self.DThread) <NEW_LINE> self.DThread.start() <NEW_LINE> self.CManager = CommandManager() <NEW_LINE> self.UThread = UserThread((self.host, self.portU), self.CManager) <NEW_LINE> self.threads.append(self.UThread) <NEW_LINE> self.UThread.start() <NEW_LINE> self.CThread = CommandThread((self.host, self.portC), self.CManager) <NEW_LINE> self.threads.append(self.CThread) <NEW_LINE> self.CThread.start() <NEW_LINE> self.IManager = InfoManager() <NEW_LINE> self.IThread = InfoThread((self.host, self.portI), self.IManager) <NEW_LINE> self.threads.append(self.IThread) <NEW_LINE> self.IThread.start() <NEW_LINE> sleep(.1) <NEW_LINE> print('Server started') <NEW_LINE> print(self) <NEW_LINE> return <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return 'Server ports: \n - data receiving: {}\n - command sending :{}\n - user receiving: {}\n - information sending: {}'.format(self.portD, self.portC, self.portU, self.portI) <NEW_LINE> <DEDENT> def stop(self): <NEW_LINE> <INDENT> for thread in self.threads: <NEW_LINE> <INDENT> ConnexionThread.stopconnexion(thread) <NEW_LINE> <DEDENT> for thread in self.threads: <NEW_LINE> <INDENT> thread.join() <NEW_LINE> <DEDENT> print("Server shut down.") <NEW_LINE> return
Main server class - can handle communication with machine, user and data saving.
62598fa292d797404e388aa6
class PollyPerformance(experiment.Experiment): <NEW_LINE> <INDENT> NAME = "pollyperformance" <NEW_LINE> def actions_for_project(self, project): <NEW_LINE> <INDENT> configs = settings.CFG["perf"]["config"].value <NEW_LINE> if configs is None: <NEW_LINE> <INDENT> warnings.warn( "({0}) should not be null.".format( repr(settings.CFG["perf"]["config"])), category=ShouldNotBeNone, stacklevel=2) <NEW_LINE> return <NEW_LINE> <DEDENT> config_list = re.split(r'\s*', configs) <NEW_LINE> config_with_llvm = [] <NEW_LINE> for config in config_list: <NEW_LINE> <INDENT> config_with_llvm.append("-mllvm") <NEW_LINE> config_with_llvm.append(config) <NEW_LINE> <DEDENT> project.cflags = [ "-O3", "-fno-omit-frame-pointer", "-Xclang", "-load", "-Xclang", "LLVMPolyJIT.so", "-mllvm", "-polly" ] + config_with_llvm <NEW_LINE> actns = [] <NEW_LINE> num_jobs = int(settings.CFG["jobs"].value) <NEW_LINE> for i in range(1, num_jobs): <NEW_LINE> <INDENT> project_i = copy.deepcopy(project) <NEW_LINE> project_i.run_uuid = uuid.uuid4() <NEW_LINE> project_i.cflags += ["-mllvm", "-polly-num-threads={0}".format(i)] <NEW_LINE> project_i.runtime_extension = extensions.run.RuntimeExtension( project_i, self, {'jobs': i}) << extensions.time.RunWithTime() <NEW_LINE> actns.extend(self.default_runtime_actions(project_i)) <NEW_LINE> <DEDENT> return actns
The polly performance experiment.
62598fa297e22403b383ad8d
class TestSystemDynamics(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> mu = 1. <NEW_LINE> self.sys = SystemDynamics(ModelCOE(mu)) <NEW_LINE> <DEDENT> def test_instantiation(self): <NEW_LINE> <INDENT> self.assertIsInstance(self.sys, SystemDynamics) <NEW_LINE> <DEDENT> def test_getattr(self): <NEW_LINE> <INDENT> self.assertIsInstance(self.sys.plant, ModelCOE) <NEW_LINE> <DEDENT> def test_setattr(self): <NEW_LINE> <INDENT> self.sys.control = PerturbZero() <NEW_LINE> self.assertIsInstance(self.sys.control, PerturbZero) <NEW_LINE> <DEDENT> def test_control(self): <NEW_LINE> <INDENT> x = np.matrix([[2., .5, 1., .1, .1, 0.], [4., .5, 1., .1, .1, 0.], [8., .5, 1., .1, .1, 0.]]) <NEW_LINE> t = np.matrix([[0.], [1.], [2.]]) <NEW_LINE> Xdot = self.sys(t, x) <NEW_LINE> self.assertEqual(Xdot.shape, (3, 6))
Test class for SystemDynamics.
62598fa207f4c71912baf2c5
class McmcProposalProbs(dict): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> object.__setattr__(self, 'comp', 1.0) <NEW_LINE> object.__setattr__(self, 'compDir', 0.0) <NEW_LINE> object.__setattr__(self, 'rjComp', 0.0) <NEW_LINE> object.__setattr__(self, 'rMatrix', 1.0) <NEW_LINE> object.__setattr__(self, 'rjRMatrix', 0.0) <NEW_LINE> object.__setattr__(self, 'gdasrv', 1.0) <NEW_LINE> object.__setattr__(self, 'pInvar', 1.0) <NEW_LINE> object.__setattr__(self, 'local', 1.0) <NEW_LINE> object.__setattr__(self, 'brLen', 0.0) <NEW_LINE> object.__setattr__(self, 'eTBR', 1.0) <NEW_LINE> object.__setattr__(self, 'polytomy', 0.0) <NEW_LINE> object.__setattr__(self, 'root3', 0.0) <NEW_LINE> object.__setattr__(self, 'compLocation', 0.0) <NEW_LINE> object.__setattr__(self, 'rMatrixLocation', 0.0) <NEW_LINE> object.__setattr__(self, 'gdasrvLocation', 0.0) <NEW_LINE> object.__setattr__(self, 'relRate', 1.0) <NEW_LINE> object.__setattr__(self, 'cmd1_compDir', 0.0) <NEW_LINE> object.__setattr__(self, 'cmd1_comp0Dir', 0.0) <NEW_LINE> object.__setattr__(self, 'cmd1_allCompDir', 0.0) <NEW_LINE> object.__setattr__(self, 'cmd1_alpha', 0.0) <NEW_LINE> <DEDENT> def __setattr__(self, item, val): <NEW_LINE> <INDENT> gm = ["\nMcmcProposalProbs(). (set %s to %s)" % (item, val)] <NEW_LINE> theKeys = list(self.__dict__.keys()) <NEW_LINE> if item in theKeys: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> val = float(val) <NEW_LINE> if val < 1e-9: <NEW_LINE> <INDENT> val = 0 <NEW_LINE> <DEDENT> object.__setattr__(self, item, val) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> gm.append("Should be a float. Got '%s'" % val) <NEW_LINE> raise Glitch(gm) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.dump() <NEW_LINE> gm.append(" Can't set '%s'-- no such proposal." % item) <NEW_LINE> raise Glitch(gm) <NEW_LINE> <DEDENT> <DEDENT> def reprString(self): <NEW_LINE> <INDENT> stuff = ["\nUser-settable relative proposal probabilities, from yourMcmc.prob"] <NEW_LINE> stuff.append(" To change it, do eg ") <NEW_LINE> stuff.append(" yourMcmc.prob.comp = 0.0 # turns comp proposals off") <NEW_LINE> stuff.append(" Current settings:") <NEW_LINE> theKeys = list(self.__dict__.keys()) <NEW_LINE> theKeys.sort() <NEW_LINE> for k in theKeys: <NEW_LINE> <INDENT> stuff.append(" %15s: %s" % (k, getattr(self, k))) <NEW_LINE> <DEDENT> return string.join(stuff, '\n') <NEW_LINE> <DEDENT> def dump(self): <NEW_LINE> <INDENT> print(self.reprString()) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return self.reprString()
User-settable relative proposal probabilities. An instance of this class is made as Mcmc.prob, where you can do, for example:: yourMcmc.prob.local = 2.0 These are relative proposal probs, that do not sum to 1.0, and affect the calculation of the final proposal probabilities (ie the kind that do sum to 1). It is a relative setting, and the default is 1.0. Setting it to 0 turns it off. For small probabilities, setting it to 2.0 doubles it. For bigger probabilities, setting it to 2.0 makes it somewhat bigger. Check the effect that it has by doing:: yourMcmc.writeProposalIntendedProbs() which prints out the final calculated probabilities.
62598fa263d6d428bbee2633
class ModelAdminMiddleware(object): <NEW_LINE> <INDENT> def process_request(self, request): <NEW_LINE> <INDENT> referer_url = request.META.get('HTTP_REFERER') <NEW_LINE> return_to_index_url = request.session.get('return_to_index_url') <NEW_LINE> try: <NEW_LINE> <INDENT> if all(( return_to_index_url, referer_url, request.method == 'GET', not request.is_ajax(), resolve(request.path).url_name in ('wagtailadmin_explore_root', 'wagtailadmin_explore'), )): <NEW_LINE> <INDENT> perform_redirection = False <NEW_LINE> referer_match = resolve(urlparse(referer_url).path) <NEW_LINE> if all(( referer_match.namespace == 'wagtailadmin_pages', referer_match.url_name in ( 'add', 'edit', 'delete', 'unpublish', 'copy' ), )): <NEW_LINE> <INDENT> perform_redirection = True <NEW_LINE> <DEDENT> elif all(( not referer_match.namespace, referer_match.url_name in ( 'wagtailadmin_pages_create', 'wagtailadmin_pages_edit', 'wagtailadmin_pages_delete', 'wagtailadmin_pages_unpublish' ), )): <NEW_LINE> <INDENT> perform_redirection = True <NEW_LINE> <DEDENT> if perform_redirection: <NEW_LINE> <INDENT> del request.session['return_to_index_url'] <NEW_LINE> return HttpResponseRedirect(return_to_index_url) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> except Resolver404: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> return None
Whenever loading wagtail's wagtailadmin_explore views, we check the session for a `return_to_list_url` value (set by some views), to see if the user should be redirected to a custom list view instead, and if so, redirect them to it.
62598fa28e7ae83300ee8f22
@implementer(IPolicyForHTTPS) <NEW_LINE> class BrowserLikePolicyForHTTPS(object): <NEW_LINE> <INDENT> def __init__(self, trustRoot=None): <NEW_LINE> <INDENT> self._trustRoot = trustRoot <NEW_LINE> <DEDENT> @_requireSSL <NEW_LINE> def creatorForNetloc(self, hostname, port): <NEW_LINE> <INDENT> return optionsForClientTLS(hostname.decode("ascii"), trustRoot=self._trustRoot)
SSL connection creator for web clients.
62598fa23cc13d1c6d4655ee
class IssueLinkRequest(NamedTuple): <NEW_LINE> <INDENT> issue_key: str <NEW_LINE> url: str <NEW_LINE> def as_dict(self) -> Dict[str, str]: <NEW_LINE> <INDENT> return {"issue_key": self.issue_key, "url": self.url}
Issue to add to a task annotation.
62598fa2fbf16365ca793f3d
class AbstractTodo: <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def query(cls, **search_parameters): <NEW_LINE> <INDENT> raise NotImplementedError( ERROR.format(cls.__class__.__name__, "query()")) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def active_todos(cls): <NEW_LINE> <INDENT> raise NotImplementedError( ERROR.format(cls.__class__.__name__, "active_todos()")) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def get_projects(cls, search_string): <NEW_LINE> <INDENT> raise NotImplementedError( ERROR.format(cls.__class__.__name__, "get_projects()")) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def new(cls, **args): <NEW_LINE> <INDENT> raise NotImplementedError( ERROR.format(cls.__class__.__name__, "new()")) <NEW_LINE> <DEDENT> def save(self): <NEW_LINE> <INDENT> raise NotImplementedError( ERROR.format(self.__class__.__name__, "save()"))
Interface for any implementation of :class:`Todo`.
62598fa2435de62698e9bc76
class HelloWorldOther2(BaseHelloWorldText): <NEW_LINE> <INDENT> def _helloWorldText(self, b): <NEW_LINE> <INDENT> b.div(color=Color('#00FFFF')) <NEW_LINE> b.text('And yet another world on this page.') <NEW_LINE> b._div()
Private method. Inheriting from *BaseHelloWorldText* component, the class name generated by @self.getClassName()@ results in @HelloWorldHome@. Color is different per page.
62598fa257b8e32f5250805c
class IFactoryNode(IApplicationNode, IChildFactory): <NEW_LINE> <INDENT> pass
Application node for static children.
62598fa2460517430c431f9c
class PrivateEndpointConnection(SubResource): <NEW_LINE> <INDENT> _validation = { 'type': {'readonly': True}, 'etag': {'readonly': True}, 'provisioning_state': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(PrivateEndpointConnection, self).__init__(**kwargs) <NEW_LINE> self.name = kwargs.get('name', None) <NEW_LINE> self.type = None <NEW_LINE> self.etag = None <NEW_LINE> self.private_endpoint = kwargs.get('private_endpoint', None) <NEW_LINE> self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) <NEW_LINE> self.provisioning_state = None
PrivateEndpointConnection resource. Variables are only populated by the server, and will be ignored when sending a request. :param id: Resource ID. :type id: str :param name: The name of the resource that is unique within a resource group. This name can be used to access the resource. :type name: str :ivar type: The resource type. :vartype type: str :ivar etag: A unique read-only string that changes whenever the resource is updated. :vartype etag: str :param private_endpoint: The resource of private end point. :type private_endpoint: ~azure.mgmt.network.v2019_08_01.models.PrivateEndpoint :param private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :type private_link_service_connection_state: ~azure.mgmt.network.v2019_08_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. Possible values include: "Succeeded", "Updating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.network.v2019_08_01.models.ProvisioningState
62598fa2e1aae11d1e7ce764
class Copy(ReceiverOption): <NEW_LINE> <INDENT> def apply(self, receiver): <NEW_LINE> <INDENT> receiver.source.distribution_mode = Terminus.DIST_MODE_COPY
Receiver option which copies messages to the receiver. This ensures that all receivers receive all incoming messages, no matter how many receivers there are. This is achieved by setting the receiver source distribution mode to :const:`proton.Terminus.DIST_MODE_COPY`.
62598fa20c0af96317c56204
class MultilangResourcesAux(): <NEW_LINE> <INDENT> def _get_lang_name(self, lang): <NEW_LINE> <INDENT> loc = Locale(lang) <NEW_LINE> return loc.display_name or loc.english_name <NEW_LINE> <DEDENT> def _format_resource_items(self, items): <NEW_LINE> <INDENT> out = h.format_resource_items(items) <NEW_LINE> new_out = [] <NEW_LINE> for key, val in items: <NEW_LINE> <INDENT> if key == 'lang' and val: <NEW_LINE> <INDENT> key = _('Language') <NEW_LINE> loc = Locale(val) <NEW_LINE> val = '{} [{}]'.format(loc.display_name or loc.english_name, str(loc)) <NEW_LINE> <DEDENT> new_out.append((key, val)) <NEW_LINE> <DEDENT> return new_out <NEW_LINE> <DEDENT> def _get_resource_schema(self): <NEW_LINE> <INDENT> return [{'name': 'lang', 'type': 'vocabulary', 'label': _('Language'), 'placeholder': _('Enter language code'), 'help': _('Set language for which this resource will be visible'), 'validators': ['ignore_missing']}] <NEW_LINE> <DEDENT> def update_schema(self, schema): <NEW_LINE> <INDENT> fields = self._get_resource_schema() <NEW_LINE> gv = toolkit.get_validator <NEW_LINE> res_schema = dict((r['name'], [gv(v) for v in r['validators']]) for r in fields) <NEW_LINE> res = schema['resources'] <NEW_LINE> res.update(res_schema) <NEW_LINE> schema['resources'] = res <NEW_LINE> return schema <NEW_LINE> <DEDENT> def read_template(self): <NEW_LINE> <INDENT> return 'package/read_multilang.html' <NEW_LINE> <DEDENT> def resource_form(self): <NEW_LINE> <INDENT> return 'package/snippets/resource_form_multilang.html' <NEW_LINE> <DEDENT> def get_helpers(self): <NEW_LINE> <INDENT> multilang_helpers = { 'get_multilang_resource_schema': self._get_resource_schema, 'format_resource_items': self._format_resource_items, 'get_lang_name': self._get_lang_name, } <NEW_LINE> return multilang_helpers
IDatasetForm has some problems when inherited more than once, so this class exposes methods for being reused by external plugins that needs the multilang resources functionality.
62598fa2baa26c4b54d4f132
class refresher(object): <NEW_LINE> <INDENT> def __init__(self, server, output_pv): <NEW_LINE> <INDENT> self.server = server <NEW_LINE> self.output_pv = output_pv <NEW_LINE> self.name = output_pv + ":REFRESH" <NEW_LINE> <DEDENT> def set(self, value=None): <NEW_LINE> <INDENT> self.server.refresh_record(self.output_pv)
This class is designed to be passed instead of a mirror record, when its set method is then called it refreshes the held PV on the held server.
62598fa24f88993c371f044b
class EntityTypesServicer(object): <NEW_LINE> <INDENT> def ListEntityTypes(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def GetEntityType(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def CreateEntityType(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def UpdateEntityType(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def DeleteEntityType(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def BatchUpdateEntityTypes(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def BatchDeleteEntityTypes(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def BatchCreateEntities(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def BatchUpdateEntities(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') <NEW_LINE> <DEDENT> def BatchDeleteEntities(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!')
Manages agent entity types. Refer to [documentation](https://dialogflow.com/docs/entities) for more # details about entity types. Standard methods.
62598fa25166f23b2e24325a
class MilkCoin(Bitcoin): <NEW_LINE> <INDENT> name = 'milkcoin' <NEW_LINE> symbols = ('MUU', ) <NEW_LINE> nodes = ("185.69.55.50", ) <NEW_LINE> port = 35235 <NEW_LINE> message_start = b'\xf1\xd5\xd1\xf2' <NEW_LINE> base58_prefixes = { 'PUBKEY_ADDR': 50, 'SCRIPT_ADDR': 55, 'SECRET_KEY': 178 }
Class with all the necessary MilkCoin network information based on https://github.com/milkcoin/milk/blob/master/src/net.cpp (date of access: 02/16/2018)
62598fa2097d151d1a2c0ead
class S3OrganisationTypeTagModel(S3Model): <NEW_LINE> <INDENT> names = ["org_organisation_type_tag"] <NEW_LINE> def model(self): <NEW_LINE> <INDENT> T = current.T <NEW_LINE> s3 = current.response.s3 <NEW_LINE> tablename = "org_organisation_type_tag" <NEW_LINE> table = self.define_table(tablename, self.org_organisation_type_id(), Field("tag", label=T("Key")), Field("value", label=("Value")), s3.comments(), *s3.meta_fields()) <NEW_LINE> return Storage( )
Organisation Type Tags
62598fa299cbb53fe6830d56
class SingleNode(object): <NEW_LINE> <INDENT> def __init__(self, item): <NEW_LINE> <INDENT> self.item = item <NEW_LINE> self.next = None
节点类型
62598fa2d268445f26639ac4
class ProjectSerializer(serializers.ModelSerializer): <NEW_LINE> <INDENT> owner = serializers.ReadOnlyField(source='owner.username', required=False) <NEW_LINE> phases = ProjectPhaseSerializer(many=True, read_only=True) <NEW_LINE> notes = NoteSerializer(many=True, required=False) <NEW_LINE> builds = TenantBuildInfoSerializer(source='tenantbuildinfo_set', many=True) <NEW_LINE> testing_cycles = TestingCycleInfoSerializer(source='testingcycleinfo_set', many=True) <NEW_LINE> class Meta: <NEW_LINE> <INDENT> model = Project <NEW_LINE> fields = ( 'id', 'name', 'client', 'methodology', 'phase_one_project', 'phases', 'active_phase', 'status', 'go_live_date', 'kickoff_date', 'first_payroll', 'scope', 'builds', 'testing_cycles', 'notes', 'owner' ) <NEW_LINE> depth = 2 <NEW_LINE> <DEDENT> def create(self, validated_data): <NEW_LINE> <INDENT> notes_data = validated_data.pop('notes') <NEW_LINE> project = Project.objects.create(**validated_data) <NEW_LINE> for note_data in notes_data: <NEW_LINE> <INDENT> Note.objects.create(project=project, **note_data) <NEW_LINE> <DEDENT> return project
This needs to be addressed ASAP
62598fa28a43f66fc4bf1ffe
class XValidation(object): <NEW_LINE> <INDENT> def __init__(self, categories, fixmat, num_slices): <NEW_LINE> <INDENT> raise NotImplementedError <NEW_LINE> <DEDENT> def generate(self, subject_partition, image_partition): <NEW_LINE> <INDENT> raise NotImplementedError
Interface for a cross-validation object.
62598fa22ae34c7f260aaf63
class ConfigFloat(ConfigOpt): <NEW_LINE> <INDENT> def __init__(self, sformat=None, **kwargs): <NEW_LINE> <INDENT> self._sformat = sformat <NEW_LINE> super(ConfigFloat, self).__init__(**kwargs) <NEW_LINE> <DEDENT> def parse(self, value): <NEW_LINE> <INDENT> if self._sformat is not None: <NEW_LINE> <INDENT> return float(self._sformat.format(float(value))) <NEW_LINE> <DEDENT> return float(value) <NEW_LINE> <DEDENT> def repr(self, value): <NEW_LINE> <INDENT> if self._sformat is not None: <NEW_LINE> <INDENT> return self._sformat.format(value) <NEW_LINE> <DEDENT> return value
Configuration option of type floating point number. Internal representation of the object is a Python ``float``. .. inheritance-diagram:: ConfigFloat :parts: 1 :param str sformat: Format to be used by :py:func:`print` to export the internal float.
62598fa23c8af77a43b67e82
class LevelCheckboxWdg(CheckboxColWdg): <NEW_LINE> <INDENT> CB_NAME = 'prod_level' <NEW_LINE> def set_cb_name(self): <NEW_LINE> <INDENT> self.name = self.CB_NAME
widget to display a checkbox in the column with select-all control
62598fa21f5feb6acb162aa5
class CCUser(models.User): <NEW_LINE> <INDENT> optional_keys = models.User.optional_keys + ('sapObjectStatus', 'ccObjectStatus', 'camObjectStatus', 'password_expires_at', 'password_failures', 'userAccountControl')
Extended user class with SAP specific user (internal) attributes
62598fa2dd821e528d6d8db8
class HybridLoader: <NEW_LINE> <INDENT> def __init__(self, db_path, ext): <NEW_LINE> <INDENT> self.db_path = db_path <NEW_LINE> self.ext = ext <NEW_LINE> if self.ext == '.npy': <NEW_LINE> <INDENT> self.loader = lambda x: np.load(x) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.loader = lambda x: np.load(x)['feat'] <NEW_LINE> <DEDENT> if db_path.endswith('.lmdb'): <NEW_LINE> <INDENT> self.db_type = 'lmdb' <NEW_LINE> self.env = lmdb.open(db_path, subdir=os.path.isdir(db_path), readonly=True, lock=False, readahead=False, meminit=False) <NEW_LINE> <DEDENT> elif db_path.endswith('.pth'): <NEW_LINE> <INDENT> self.db_type = 'pth' <NEW_LINE> self.feat_file = torch.load(db_path) <NEW_LINE> self.loader = lambda x: x <NEW_LINE> print('HybridLoader: ext is ignored') <NEW_LINE> <DEDENT> elif db_path.endswith('h5'): <NEW_LINE> <INDENT> self.db_type = 'h5' <NEW_LINE> self.loader = lambda x: np.array(x).astype('float32') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.db_type = 'dir' <NEW_LINE> <DEDENT> <DEDENT> def get(self, key): <NEW_LINE> <INDENT> if self.db_type == 'lmdb': <NEW_LINE> <INDENT> env = self.env <NEW_LINE> with env.begin(write=False) as txn: <NEW_LINE> <INDENT> byteflow = txn.get(key.encode()) <NEW_LINE> <DEDENT> f_input = six.BytesIO(byteflow) <NEW_LINE> <DEDENT> elif self.db_type == 'pth': <NEW_LINE> <INDENT> f_input = self.feat_file[key] <NEW_LINE> <DEDENT> elif self.db_type == 'h5': <NEW_LINE> <INDENT> f_input = h5py.File(self.db_path, 'r')[key] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> f_input = os.path.join(self.db_path, key + self.ext) <NEW_LINE> <DEDENT> feat = self.loader(f_input) <NEW_LINE> return feat
If db_path is a director, then use normal file loading If lmdb, then load from lmdb The loading method depend on extention.
62598fa22ae34c7f260aaf64
class BoundingBoxSampleAnnotation: <NEW_LINE> <INDENT> __slots__ = ('value', 'top') <NEW_LINE> storage_signature = 'std_bboxes' <NEW_LINE> def __init__(self, prealloc_obj = 0): <NEW_LINE> <INDENT> self.value = ndarray((4, prealloc_obj), dtype = 'int32', order = 'C') <NEW_LINE> self.top = 0 <NEW_LINE> <DEDENT> def add_record(self, values): <NEW_LINE> <INDENT> if self.top < self.value.shape[1]: <NEW_LINE> <INDENT> self.value[:, self.top] = values <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.value = hstack((self.value, column_stack((values,)))) <NEW_LINE> <DEDENT> self.top += 1
The class stores single matrix which represents all bounding boxes on given sample (which is supposed to be a single image). The data layout is designed to accelerate matrix operations such as selecting max or min on one feature channel (for instance, x_min or y_max), not one bounding box. So note that the data is stored row-wise, a bounding box is a column in the matrix.
62598fa2435de62698e9bc77
class JobMatch(models.Model): <NEW_LINE> <INDENT> user = models.ForeignKey(User, verbose_name=_("User"), on_delete=models.CASCADE) <NEW_LINE> job = models.ForeignKey(Job, verbose_name=_("Job"), on_delete=models.CASCADE, null=True, blank=True) <NEW_LINE> show = models.BooleanField(_("Show"), default=True) <NEW_LINE> class Meta: <NEW_LINE> <INDENT> verbose_name = 'JobMatch' <NEW_LINE> verbose_name_plural = 'JobMatchs' <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.job.position
Model definition for JobMatch.
62598fa2d7e4931a7ef3bf1d
class SPECIAL(GenericSeminar): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> @cached_property <NEW_LINE> def talks(self): <NEW_LINE> <INDENT> eastern = timezone('US/Eastern') <NEW_LINE> filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),'special.yaml') <NEW_LINE> res = [] <NEW_LINE> with open(filename, 'r') as F: <NEW_LINE> <INDENT> for elt in yaml.safe_load(F): <NEW_LINE> <INDENT> if elt.get('speaker'): <NEW_LINE> <INDENT> elt['label'] = "special" <NEW_LINE> elt['time'] = elt['time'].replace(tzinfo=utc).astimezone(eastern) <NEW_LINE> elt['endtime'] = elt['endtime'].replace(tzinfo=utc).astimezone(eastern) <NEW_LINE> self.clean_talk(elt) <NEW_LINE> res.append(elt) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return res
class used for special seminars, like yearly events
62598fa27d847024c075c24a
class ConnectionMonitorTcpConfiguration(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'port': {'key': 'port', 'type': 'int'}, 'disable_trace_route': {'key': 'disableTraceRoute', 'type': 'bool'}, } <NEW_LINE> def __init__( self, *, port: Optional[int] = None, disable_trace_route: Optional[bool] = None, **kwargs ): <NEW_LINE> <INDENT> super(ConnectionMonitorTcpConfiguration, self).__init__(**kwargs) <NEW_LINE> self.port = port <NEW_LINE> self.disable_trace_route = disable_trace_route
Describes the TCP configuration. :param port: The port to connect to. :type port: int :param disable_trace_route: Value indicating whether path evaluation with trace route should be disabled. :type disable_trace_route: bool
62598fa22c8b7c6e89bd3649
class CircularList(list): <NEW_LINE> <INDENT> def __getitem__(self, index): <NEW_LINE> <INDENT> index = index % self.__len__() <NEW_LINE> return super().__getitem__(index)
>>> l = CircularList([1, 2, 3]) >>> l [1, 2, 3] >>> l[2] 3 >>> l[3] 1 >>> l[100] 2 >>>
62598fa28e7ae83300ee8f24
class Bless(Spell): <NEW_LINE> <INDENT> name = "Bless" <NEW_LINE> level = 1 <NEW_LINE> casting_time = "1 action" <NEW_LINE> casting_range = "30 feet" <NEW_LINE> components = ('V', 'S', 'M') <NEW_LINE> materials = """A sprinkling of holy water""" <NEW_LINE> duration = "Concentration, up to 1 minute" <NEW_LINE> ritual = False <NEW_LINE> magic_school = "Enchantment" <NEW_LINE> classes = ('Cleric', 'Paladin')
You bless up to three creatures of your choice within range. Whenever a target makes an attack roll or a saving throw before the spell ends, the target can roll a d4 and add the number rolled to the attack roll or saving throw. At Higher Levels: When you cast this spell using a spell slot of 2nd level or higher, you can target one additional creature for each slot level above 1st.
62598fa245492302aabfc354
class Tree: <NEW_LINE> <INDENT> def __init__(self, state=None, score=None, children=None, m=None) -> None: <NEW_LINE> <INDENT> self.state = state <NEW_LINE> self.score = score <NEW_LINE> self.children = children[:] if children is not None else [] <NEW_LINE> self.move = m
A bare-bones Tree ADT that identifies the root with the entire tree.
62598fa2435de62698e9bc78
class TransmissionSensor(Entity): <NEW_LINE> <INDENT> def __init__(self, sensor_type, transmission_client, client_name): <NEW_LINE> <INDENT> self._name = SENSOR_TYPES[sensor_type][0] <NEW_LINE> self.tm_client = transmission_client <NEW_LINE> self.type = sensor_type <NEW_LINE> self.client_name = client_name <NEW_LINE> self._state = None <NEW_LINE> self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] <NEW_LINE> <DEDENT> @property <NEW_LINE> def name(self): <NEW_LINE> <INDENT> return '{} {}'.format(self.client_name, self._name) <NEW_LINE> <DEDENT> @property <NEW_LINE> def state(self): <NEW_LINE> <INDENT> return self._state <NEW_LINE> <DEDENT> @property <NEW_LINE> def unit_of_measurement(self): <NEW_LINE> <INDENT> return self._unit_of_measurement <NEW_LINE> <DEDENT> def refresh_transmission_data(self): <NEW_LINE> <INDENT> from transmissionrpc.error import TransmissionError <NEW_LINE> if _THROTTLED_REFRESH is not None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _THROTTLED_REFRESH() <NEW_LINE> <DEDENT> except TransmissionError: <NEW_LINE> <INDENT> _LOGGER.error("Connection to Transmission API failed") <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def update(self): <NEW_LINE> <INDENT> self.refresh_transmission_data() <NEW_LINE> if self.type == 'current_status': <NEW_LINE> <INDENT> if self.tm_client.session: <NEW_LINE> <INDENT> upload = self.tm_client.session.uploadSpeed <NEW_LINE> download = self.tm_client.session.downloadSpeed <NEW_LINE> if upload > 0 and download > 0: <NEW_LINE> <INDENT> self._state = 'Up/Down' <NEW_LINE> <DEDENT> elif upload > 0 and download == 0: <NEW_LINE> <INDENT> self._state = 'Seeding' <NEW_LINE> <DEDENT> elif upload == 0 and download > 0: <NEW_LINE> <INDENT> self._state = 'Downloading' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._state = STATE_IDLE <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self._state = None <NEW_LINE> <DEDENT> <DEDENT> if self.tm_client.session: <NEW_LINE> <INDENT> if self.type == 'download_speed': <NEW_LINE> <INDENT> mb_spd = float(self.tm_client.session.downloadSpeed) <NEW_LINE> mb_spd = mb_spd / 1024 / 1024 <NEW_LINE> self._state = round(mb_spd, 2 if mb_spd < 0.1 else 1) <NEW_LINE> <DEDENT> elif self.type == 'upload_speed': <NEW_LINE> <INDENT> mb_spd = float(self.tm_client.session.uploadSpeed) <NEW_LINE> mb_spd = mb_spd / 1024 / 1024 <NEW_LINE> self._state = round(mb_spd, 2 if mb_spd < 0.1 else 1) <NEW_LINE> <DEDENT> elif self.type == 'active_torrents': <NEW_LINE> <INDENT> self._state = self.tm_client.session.activeTorrentCount
Representation of a Transmission sensor.
62598fa266656f66f7d5a275
class HKSAL7(FinTS3Segment): <NEW_LINE> <INDENT> account = DataElementGroupField(type=KTI1, _d="Kontoverbindung international") <NEW_LINE> all_accounts = DataElementField(type='jn', _d="Alle Konten") <NEW_LINE> max_number_responses = DataElementField(type='num', max_length=4, required=False, _d="Maximale Anzahl Einträge") <NEW_LINE> touchdown_point = DataElementField(type='an', max_length=35, required=False, _d="Aufsetzpunkt")
Saldenabfrage, version 7 Source: FinTS Financial Transaction Services, Schnittstellenspezifikation, Messages -- Multibankfähige Geschäftsvorfälle
62598fa324f1403a926857f5
class SetAuditConfigRequest(JDCloudRequest): <NEW_LINE> <INDENT> def __init__(self, parameters, header=None, version="v1"): <NEW_LINE> <INDENT> super(SetAuditConfigRequest, self).__init__( '/regions/{regionId}/agents', 'PATCH', header, version) <NEW_LINE> self.parameters = parameters
配置数据库审计信息
62598fa3498bea3a75a579a6
class ESP(object): <NEW_LINE> <INDENT> def __init__(self, port,baud=19200): <NEW_LINE> <INDENT> self.lock = threading.Lock() <NEW_LINE> try: <NEW_LINE> <INDENT> self.ser = serial.Serial(port=port, baudrate=baud, bytesize=8, timeout=1, parity='N', rtscts=1) <NEW_LINE> self.Abort = self.abort <NEW_LINE> ve = self.version <NEW_LINE> if ve == "": raise Exception("Port %s exists but did not get any reply from ESP controller"%port) <NEW_LINE> <DEDENT> except serial.SerialException: <NEW_LINE> <INDENT> self.ser = None <NEW_LINE> print("Cannot connect to ESP controller via "+port) <NEW_LINE> raise Exception("Could not find (or write) to port "+port) <NEW_LINE> <DEDENT> <DEDENT> def __del__(self): <NEW_LINE> <INDENT> if self.ser is not None: self.ser.close() <NEW_LINE> <DEDENT> def read(self): <NEW_LINE> <INDENT> if self.ser is None: return None <NEW_LINE> with DelayedKeyboardInterrupt(): <NEW_LINE> <INDENT> str = self.ser.readline() <NEW_LINE> str = str.decode('ascii') <NEW_LINE> <DEDENT> return str[0:-2] <NEW_LINE> <DEDENT> def write(self, string, axis=None): <NEW_LINE> <INDENT> if self.ser is None: return None <NEW_LINE> cmd = (str(axis) if axis is not None else "") + string + "\r" <NEW_LINE> self.ser.write(cmd.encode('ascii')) <NEW_LINE> <DEDENT> def query(self, string, axis=None, check_error=False): <NEW_LINE> <INDENT> if self.ser is None: return None <NEW_LINE> with self.lock: <NEW_LINE> <INDENT> if check_error: <NEW_LINE> <INDENT> self.raise_error() <NEW_LINE> <DEDENT> self.write(string+'?', axis=axis) <NEW_LINE> if check_error: <NEW_LINE> <INDENT> self.raise_error() <NEW_LINE> <DEDENT> return self.read() <NEW_LINE> <DEDENT> <DEDENT> @property <NEW_LINE> def version(self): <NEW_LINE> <INDENT> return self.query('VE') <NEW_LINE> <DEDENT> def abort(self): <NEW_LINE> <INDENT> self.write('AB') <NEW_LINE> <DEDENT> def read_error(self): <NEW_LINE> <INDENT> return self.query('TB') <NEW_LINE> <DEDENT> def raise_error(self): <NEW_LINE> <INDENT> err = self.read_error() <NEW_LINE> if err[0] != "0": <NEW_LINE> <INDENT> raise NewportError(err) <NEW_LINE> <DEDENT> <DEDENT> def axis(self, axis_index=1): <NEW_LINE> <INDENT> return Axis(self, axis=axis_index)
Driver for Newport's ESP (100/300) motion controller. :Usage: >>> esp = NewportESP.ESP('/dev/ttyUSB0') # open communication with controller >>> stage = esp.axis(1) # open axis no 1
62598fa338b623060ffa8f18
class FileTypes(Enum): <NEW_LINE> <INDENT> surface = 1 <NEW_LINE> sounding = 2 <NEW_LINE> grid = 3
GEMPAK file type.
62598fa330dc7b766599f6d2
class MedicalInfoForSection(PacketsForSection): <NEW_LINE> <INDENT> template_name = 'trips/medical_packet.html'
Packets for croos, by section. Contains leader and trippee med information.
62598fa3fff4ab517ebcd66a
class RedfishSystemBiosNotFoundError( Exception ): <NEW_LINE> <INDENT> pass
Raised when the BIOS resource cannot be found
62598fa38a43f66fc4bf2001
class ConfigurationConfig(AppConfig): <NEW_LINE> <INDENT> name = "satchmo.configuration" <NEW_LINE> verbose_name = "Configuration" <NEW_LINE> def ready(self): <NEW_LINE> <INDENT> pass
Configuration app.
62598fa3e5267d203ee6b791
class Ingredient: <NEW_LINE> <INDENT> def __init__(self, food_product, amount=None, weight_unit=None, amount_type=1): <NEW_LINE> <INDENT> self.food_product = food_product <NEW_LINE> self.amount = amount <NEW_LINE> self.amount_type = amount_type <NEW_LINE> self.weight_unit = weight_unit <NEW_LINE> if AMOUNT_TYPE[self.amount_type] == 'weight': <NEW_LINE> <INDENT> self.weight = amount <NEW_LINE> <DEDENT> elif AMOUNT_TYPE[self.amount_type] == 'quantity': <NEW_LINE> <INDENT> self.weight = int(amount) * (1 / food_product.quantityToWeightRatio) <NEW_LINE> <DEDENT> <DEDENT> def calculateMacros(self): <NEW_LINE> <INDENT> ingredient_macros = copy.deepcopy(self.food_product.macros) <NEW_LINE> ingredient_macros.multiply_macros_by(10 * self.weight) <NEW_LINE> return ingredient_macros <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> if AMOUNT_TYPE[self.amount_type] == 'weight': <NEW_LINE> <INDENT> return '{}{}-{}'.format(self.weight, self.weight_unit, self.food_product) <NEW_LINE> <DEDENT> elif AMOUNT_TYPE[self.amount_type] == 'quantity': <NEW_LINE> <INDENT> return '{}-{}'.format(self.amount, self.food_product) <NEW_LINE> <DEDENT> elif AMOUNT_TYPE[self.amount_type] == 'indefinite': <NEW_LINE> <INDENT> return '{}'.format(self.food_product)
Ingredient of a meal
62598fa3498bea3a75a579a7
class Category(models.Model): <NEW_LINE> <INDENT> index_weight = 100 <NEW_LINE> trade = models.ForeignKey(Trade,verbose_name=_("trade"),null=True,blank=True) <NEW_LINE> parent = models.ForeignKey('self',verbose_name=_("parent"),null=True,blank=True) <NEW_LINE> code = models.CharField(_("code"),max_length=const.DB_CHAR_CODE_6,null=True,blank=True) <NEW_LINE> name = models.CharField(_("name"),max_length=const.DB_CHAR_NAME_120) <NEW_LINE> path = models.CharField(_("path"),max_length=const.DB_CHAR_NAME_200,null=True,blank=True) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return '%s' % self.name <NEW_LINE> <DEDENT> class Meta: <NEW_LINE> <INDENT> verbose_name = _('category') <NEW_LINE> verbose_name_plural = _('category')
分类
62598fa33617ad0b5ee05fd7
class HeapPriorityQueue(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self._heap = [] <NEW_LINE> self._dict = {} <NEW_LINE> <DEDENT> def push(self, item): <NEW_LINE> <INDENT> heapq.heappush(self._heap, (item.prio, item.key)) <NEW_LINE> self._dict[item.key] = item <NEW_LINE> <DEDENT> def pop(self): <NEW_LINE> <INDENT> key = heapq.heappop(self._heap)[1] <NEW_LINE> item = self._dict.pop(key) <NEW_LINE> return item <NEW_LINE> <DEDENT> def __contains__(self, key): <NEW_LINE> <INDENT> return key in self._dict <NEW_LINE> <DEDENT> def get_item(self, key): <NEW_LINE> <INDENT> return self._dict[key] <NEW_LINE> <DEDENT> def is_empty(self): <NEW_LINE> <INDENT> return len(self._heap) == 0 <NEW_LINE> <DEDENT> def size(self): <NEW_LINE> <INDENT> return len(self._heap) <NEW_LINE> <DEDENT> def lowest_prio(self): <NEW_LINE> <INDENT> if self.is_empty(): <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self._heap[0][0] <NEW_LINE> <DEDENT> <DEDENT> def update_queue(self, newnode): <NEW_LINE> <INDENT> oldnode = self._dict[newnode.key] <NEW_LINE> self._heap.remove((oldnode.prio, oldnode.key)) <NEW_LINE> heapq.heapify(self._heap) <NEW_LINE> self.push(newnode) <NEW_LINE> <DEDENT> def remove_everything_before_wp_index(self, input_wpi): <NEW_LINE> <INDENT> new_heap = [] <NEW_LINE> for entry in self._heap: <NEW_LINE> <INDENT> key = entry[1] <NEW_LINE> if key[-1] >= input_wpi: <NEW_LINE> <INDENT> new_heap.append(entry) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._dict.pop(key) <NEW_LINE> <DEDENT> <DEDENT> self._heap = new_heap <NEW_LINE> heapq.heapify(self._heap)
Priority queue based on heapq module.
62598fa38c0ade5d55dc35d2
class QueryEditorCtrl(wx.TextCtrl): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> wx.TextCtrl.__init__(self, *args, **kwargs)
MySQL Query Editor control.
62598fa3d58c6744b42dc216
class Robot(Circle): <NEW_LINE> <INDENT> def __init__(self, pos): <NEW_LINE> <INDENT> center = Point(pos, Y_VALUE) <NEW_LINE> super().__init__(center, 7) <NEW_LINE> self.setOutline('green') <NEW_LINE> self.draw(p.win) <NEW_LINE> self.reverse = False <NEW_LINE> <DEDENT> def getPos(self): <NEW_LINE> <INDENT> return self.getCenter().x <NEW_LINE> <DEDENT> def move(self, dx): <NEW_LINE> <INDENT> if self.reverse: dx = -dx <NEW_LINE> super().move(dx, 0)
A naive object with a few helper methods.
62598fa3435de62698e9bc79
class SimpleDictCache(NoCache): <NEW_LINE> <INDENT> def __init__(self, cache_name='default', timeout=None, public=None, private=None, *args, **kwargs): <NEW_LINE> <INDENT> super(SimpleDictCache, self).__init__(*args, **kwargs) <NEW_LINE> self.serializer = UTCSerializer() <NEW_LINE> self.timeout = timeout or self.cache.default_timeout <NEW_LINE> self.public = public <NEW_LINE> self.private = private <NEW_LINE> <DEDENT> def get(self, key, **kwargs): <NEW_LINE> <INDENT> return cache.get(key, **kwargs) <NEW_LINE> <DEDENT> def set(self, key, value, timeout=None): <NEW_LINE> <INDENT> data = self.serializer.to_simple(value, {}) <NEW_LINE> if timeout is None: <NEW_LINE> <INDENT> timeout = self.timeout <NEW_LINE> <DEDENT> cache.set(key, data, 3600) <NEW_LINE> return data <NEW_LINE> <DEDENT> def delete(self, key): <NEW_LINE> <INDENT> cache.delete(key) <NEW_LINE> <DEDENT> def cache_control(self): <NEW_LINE> <INDENT> control = { 'max_age': self.timeout, 's_maxage': self.timeout, } <NEW_LINE> if self.public is not None: <NEW_LINE> <INDENT> control["public"] = self.public <NEW_LINE> <DEDENT> if self.private is not None: <NEW_LINE> <INDENT> control["private"] = self.private <NEW_LINE> <DEDENT> return control
Uses Django's current ``CACHES`` configuration to store cached data.
62598fa38da39b475be03066
class Pokemon_Stats: <NEW_LINE> <INDENT> def __init__(self, root, type1, type2, height, weight, entry): <NEW_LINE> <INDENT> self.frame = Frame(root) <NEW_LINE> self.labels = [] <NEW_LINE> self.pokemon = (type1, type2, height, weight, entry) <NEW_LINE> self.create_widgets() <NEW_LINE> self.frame.pack() <NEW_LINE> <DEDENT> def create_widgets(self): <NEW_LINE> <INDENT> for stat in self.pokemon: <NEW_LINE> <INDENT> label = Label(self.frame, text=stat) <NEW_LINE> label.pack() <NEW_LINE> self.labels.append(label) <NEW_LINE> <DEDENT> <DEDENT> def update_labels(self): <NEW_LINE> <INDENT> for i in range(5): <NEW_LINE> <INDENT> self.labels[i].config(text=self.pokemon[i])
Frame for Pokémon stats
62598fa3be8e80087fbbeee6
class H6(H): <NEW_LINE> <INDENT> __slots__ = () <NEW_LINE> tagName = "h6"
Defines the least important heading
62598fa30c0af96317c56207
class ComputeTargetInstancesListRequest(_messages.Message): <NEW_LINE> <INDENT> filter = _messages.StringField(1) <NEW_LINE> maxResults = _messages.IntegerField(2, variant=_messages.Variant.UINT32, default=500) <NEW_LINE> orderBy = _messages.StringField(3) <NEW_LINE> pageToken = _messages.StringField(4) <NEW_LINE> project = _messages.StringField(5, required=True) <NEW_LINE> zone = _messages.StringField(6, required=True)
A ComputeTargetInstancesListRequest object. Fields: filter: Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string. The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. You can filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values. To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters. maxResults: The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) orderBy: Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by name or creationTimestamp desc is supported. pageToken: Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. project: Project ID for this request. zone: Name of the zone scoping this request.
62598fa332920d7e50bc5edc
class GroupActivityView(ListView): <NEW_LINE> <INDENT> template_name = 'groups/activity.html' <NEW_LINE> group = None <NEW_LINE> def get_queryset(self): <NEW_LINE> <INDENT> if not self.group: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> members = ([(member.user.id) for member in self.group.member_queryset()]) <NEW_LINE> return Action.objects.filter(public=True, actor_object_id__in=members, )[:15] <NEW_LINE> <DEDENT> <DEDENT> def get(self, request, *args, **kwargs): <NEW_LINE> <INDENT> self.group = None <NEW_LINE> group = get_object_or_404(GroupProfile, slug=kwargs.get('slug')) <NEW_LINE> if not group.can_view(request.user): <NEW_LINE> <INDENT> raise Http404() <NEW_LINE> <DEDENT> self.group = group <NEW_LINE> return super(GroupActivityView, self).get(request, *args, **kwargs) <NEW_LINE> <DEDENT> def get_context_data(self, **kwargs): <NEW_LINE> <INDENT> def getKey(action): <NEW_LINE> <INDENT> return action.timestamp <NEW_LINE> <DEDENT> context = super(GroupActivityView, self).get_context_data(**kwargs) <NEW_LINE> context['group'] = self.group <NEW_LINE> members = ([(member.user.id) for member in self.group.member_queryset()]) <NEW_LINE> action_list = [] <NEW_LINE> actions = Action.objects.filter( public=True, action_object_content_type__model='layer') <NEW_LINE> context['action_list_layers'] = [ action for action in actions if action.action_object.group == self.group.group][:15] <NEW_LINE> action_list.extend(context['action_list_layers']) <NEW_LINE> actions = Action.objects.filter( public=True, action_object_content_type__model='map')[:15] <NEW_LINE> context['action_list_maps'] = [ action for action in actions if action.action_object.group == self.group.group][:15] <NEW_LINE> action_list.extend(context['action_list_maps']) <NEW_LINE> context['action_list_comments'] = Action.objects.filter( public=True, actor_object_id__in=members, action_object_content_type__model='comment')[:15] <NEW_LINE> action_list.extend(context['action_list_comments']) <NEW_LINE> context['action_list'] = sorted(action_list, key=getKey, reverse=True) <NEW_LINE> return context
Returns recent group activity.
62598fa32c8b7c6e89bd364c
class EntryItem(Item): <NEW_LINE> <INDENT> title = Field() <NEW_LINE> date = Field() <NEW_LINE> text = Field()
A blog entry.
62598fa3cc0a2c111447ae94
class AssertionCombiner(object): <NEW_LINE> <INDENT> def __init__(self, license): <NEW_LINE> <INDENT> self.license = license <NEW_LINE> <DEDENT> def handle_file(self, input_filename, output_file): <NEW_LINE> <INDENT> combine_assertions([input_filename], output_file, self.license)
A class that wraps the combine_assertions function, so it can be tested in the same way as the readers, despite its extra parameters.
62598fa363d6d428bbee2638
class NodePath(Node): <NEW_LINE> <INDENT> def __init__(self, parent, isGroup, name): <NEW_LINE> <INDENT> assert isinstance(name, str) and name != '', 'Invalid node name %s' % name <NEW_LINE> self.name = name <NEW_LINE> self._match = MatchString(self, name) <NEW_LINE> super().__init__(parent, isGroup, ORDER_PATH) <NEW_LINE> <DEDENT> def tryMatch(self, converterPath, paths): <NEW_LINE> <INDENT> assert isinstance(converterPath, ConverterPath), 'Invalid converter path %s' % converterPath <NEW_LINE> assert isinstance(paths, deque), 'Invalid paths %s' % paths <NEW_LINE> assert len(paths) > 0, 'No path element in paths %s' % paths <NEW_LINE> if converterPath.normalize(self._match.value) == paths[0]: <NEW_LINE> <INDENT> del paths[0] <NEW_LINE> return self._match <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> def newMatch(self): <NEW_LINE> <INDENT> return self._match <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> if isinstance(other, NodePath): <NEW_LINE> <INDENT> return self.name == other.name <NEW_LINE> <DEDENT> return False <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return '<%s[%s]>' % (self.__class__.__name__, self.name)
Provides a node that matches a simple string path element. @see: Node
62598fa316aa5153ce400387
@implementer(IVocabularyFactory) <NEW_LINE> class LicensesVocabulary(object): <NEW_LINE> <INDENT> def __call__(self, context): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> licenses = api.portal.get_registry_record( 'rdfmarshaller_licenses', interface=ILicenses) <NEW_LINE> items = [ SimpleTerm(str(y), str(y), str(y)) for y in [ x.get('id') for x in licenses] ] <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> items = [SimpleTerm(' ', ' ', ' ')] <NEW_LINE> <DEDENT> return SimpleVocabulary(items)
LicensesVocabularyFactory
62598fa356b00c62f0fb2738
class itkNearestNeighborInterpolateImageFunctionID2D(itkInterpolateImageFunctionPython.itkInterpolateImageFunctionID2D): <NEW_LINE> <INDENT> thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') <NEW_LINE> def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") <NEW_LINE> __repr__ = _swig_repr <NEW_LINE> ImageDimension = _itkNearestNeighborInterpolateImageFunctionPython.itkNearestNeighborInterpolateImageFunctionID2D_ImageDimension <NEW_LINE> def __New_orig__(): <NEW_LINE> <INDENT> return _itkNearestNeighborInterpolateImageFunctionPython.itkNearestNeighborInterpolateImageFunctionID2D___New_orig__() <NEW_LINE> <DEDENT> __New_orig__ = staticmethod(__New_orig__) <NEW_LINE> __swig_destroy__ = _itkNearestNeighborInterpolateImageFunctionPython.delete_itkNearestNeighborInterpolateImageFunctionID2D <NEW_LINE> def cast(*args): <NEW_LINE> <INDENT> return _itkNearestNeighborInterpolateImageFunctionPython.itkNearestNeighborInterpolateImageFunctionID2D_cast(*args) <NEW_LINE> <DEDENT> cast = staticmethod(cast) <NEW_LINE> def GetPointer(self): <NEW_LINE> <INDENT> return _itkNearestNeighborInterpolateImageFunctionPython.itkNearestNeighborInterpolateImageFunctionID2D_GetPointer(self) <NEW_LINE> <DEDENT> def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkNearestNeighborInterpolateImageFunctionID2D.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj <NEW_LINE> <DEDENT> New = staticmethod(New)
Proxy of C++ itkNearestNeighborInterpolateImageFunctionID2D class
62598fa330dc7b766599f6d4
class Map(object): <NEW_LINE> <INDENT> def __init__(self, filename=params['DEFAULT_MAP']): <NEW_LINE> <INDENT> self.obstacles = pygame.sprite.Group() <NEW_LINE> self.ground = pygame.sprite.Group() <NEW_LINE> self.obs_coords = set() <NEW_LINE> self.ground_coords = set() <NEW_LINE> cur_path = os.getcwd() <NEW_LINE> map_path = os.path.join(cur_path, params['MAP_FOLDER'], filename) <NEW_LINE> with open(map_path, 'r') as map_file: <NEW_LINE> <INDENT> for i, line in enumerate(map_file): <NEW_LINE> <INDENT> for j in xrange(params['TILE_COUNT']): <NEW_LINE> <INDENT> c = (j, i) <NEW_LINE> if line[j] == '*': <NEW_LINE> <INDENT> self.obs_coords.add(c) <NEW_LINE> self.obstacles.add(Obstacle(c)) <NEW_LINE> <DEDENT> elif line[j] == '-': <NEW_LINE> <INDENT> self.ground_coords.add(c) <NEW_LINE> self.ground.add(Ground(c)) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> <DEDENT> def draw(self, screen): <NEW_LINE> <INDENT> self.obstacles.draw(screen) <NEW_LINE> self.ground.draw(screen)
Represents all obstacle on map
62598fa34f88993c371f044d
class StationMagnitudeContributionIndex(_object): <NEW_LINE> <INDENT> __swig_setmethods__ = {} <NEW_LINE> __setattr__ = lambda self, name, value: _swig_setattr(self, StationMagnitudeContributionIndex, name, value) <NEW_LINE> __swig_getmethods__ = {} <NEW_LINE> __getattr__ = lambda self, name: _swig_getattr(self, StationMagnitudeContributionIndex, name) <NEW_LINE> __repr__ = _swig_repr <NEW_LINE> def __init__(self, *args): <NEW_LINE> <INDENT> this = _DataModel.new_StationMagnitudeContributionIndex(*args) <NEW_LINE> try: <NEW_LINE> <INDENT> self.this.append(this) <NEW_LINE> <DEDENT> except __builtin__.Exception: <NEW_LINE> <INDENT> self.this = this <NEW_LINE> <DEDENT> <DEDENT> def __eq__(self, arg2): <NEW_LINE> <INDENT> return _DataModel.StationMagnitudeContributionIndex___eq__(self, arg2) <NEW_LINE> <DEDENT> def __ne__(self, arg2): <NEW_LINE> <INDENT> return _DataModel.StationMagnitudeContributionIndex___ne__(self, arg2) <NEW_LINE> <DEDENT> __swig_setmethods__["stationMagnitudeID"] = _DataModel.StationMagnitudeContributionIndex_stationMagnitudeID_set <NEW_LINE> __swig_getmethods__["stationMagnitudeID"] = _DataModel.StationMagnitudeContributionIndex_stationMagnitudeID_get <NEW_LINE> if _newclass: <NEW_LINE> <INDENT> stationMagnitudeID = _swig_property(_DataModel.StationMagnitudeContributionIndex_stationMagnitudeID_get, _DataModel.StationMagnitudeContributionIndex_stationMagnitudeID_set) <NEW_LINE> <DEDENT> __swig_destroy__ = _DataModel.delete_StationMagnitudeContributionIndex <NEW_LINE> __del__ = lambda self: None
Proxy of C++ Seiscomp::DataModel::StationMagnitudeContributionIndex class.
62598fa37047854f4633f25f
class EC3POInterfaceError(c.InterfaceError): <NEW_LINE> <INDENT> pass
Error class to raise in ec3po interface issues.
62598fa3498bea3a75a579a9
class AtwDeviceZoneClimate(MelCloudClimate): <NEW_LINE> <INDENT> _attr_max_temp = 30 <NEW_LINE> _attr_min_temp = 10 <NEW_LINE> _attr_supported_features = SUPPORT_TARGET_TEMPERATURE <NEW_LINE> def __init__( self, device: MelCloudDevice, atw_device: AtwDevice, atw_zone: Zone ) -> None: <NEW_LINE> <INDENT> super().__init__(device) <NEW_LINE> self._device = atw_device <NEW_LINE> self._zone = atw_zone <NEW_LINE> self._attr_name = f"{device.name} {self._zone.name}" <NEW_LINE> self._attr_unique_id = f"{self.api.device.serial}-{atw_zone.zone_index}" <NEW_LINE> <DEDENT> @property <NEW_LINE> def extra_state_attributes(self) -> dict[str, Any]: <NEW_LINE> <INDENT> data = { ATTR_STATUS: ATW_ZONE_HVAC_MODE_LOOKUP.get( self._zone.status, self._zone.status ) } <NEW_LINE> return data <NEW_LINE> <DEDENT> @property <NEW_LINE> def hvac_mode(self) -> str: <NEW_LINE> <INDENT> mode = self._zone.operation_mode <NEW_LINE> if not self._device.power or mode is None: <NEW_LINE> <INDENT> return HVAC_MODE_OFF <NEW_LINE> <DEDENT> return ATW_ZONE_HVAC_MODE_LOOKUP.get(mode, HVAC_MODE_OFF) <NEW_LINE> <DEDENT> async def async_set_hvac_mode(self, hvac_mode: str) -> None: <NEW_LINE> <INDENT> if hvac_mode == HVAC_MODE_OFF: <NEW_LINE> <INDENT> await self._device.set({"power": False}) <NEW_LINE> return <NEW_LINE> <DEDENT> operation_mode = ATW_ZONE_HVAC_MODE_REVERSE_LOOKUP.get(hvac_mode) <NEW_LINE> if operation_mode is None: <NEW_LINE> <INDENT> raise ValueError(f"Invalid hvac_mode [{hvac_mode}]") <NEW_LINE> <DEDENT> if self._zone.zone_index == 1: <NEW_LINE> <INDENT> props = {PROPERTY_ZONE_1_OPERATION_MODE: operation_mode} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> props = {PROPERTY_ZONE_2_OPERATION_MODE: operation_mode} <NEW_LINE> <DEDENT> if self.hvac_mode == HVAC_MODE_OFF: <NEW_LINE> <INDENT> props["power"] = True <NEW_LINE> <DEDENT> await self._device.set(props) <NEW_LINE> <DEDENT> @property <NEW_LINE> def hvac_modes(self) -> list[str]: <NEW_LINE> <INDENT> return [self.hvac_mode] <NEW_LINE> <DEDENT> @property <NEW_LINE> def current_temperature(self) -> float | None: <NEW_LINE> <INDENT> return self._zone.room_temperature <NEW_LINE> <DEDENT> @property <NEW_LINE> def target_temperature(self) -> float | None: <NEW_LINE> <INDENT> return self._zone.target_temperature <NEW_LINE> <DEDENT> async def async_set_temperature(self, **kwargs) -> None: <NEW_LINE> <INDENT> await self._zone.set_target_temperature( kwargs.get("temperature", self.target_temperature) )
Air-to-Water zone climate device.
62598fa39c8ee823130400b2
class TestZendeskIntegration(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def testZendeskIntegration(self): <NEW_LINE> <INDENT> pass
ZendeskIntegration unit test stubs
62598fa3379a373c97d98e98
class MapWrapper(object): <NEW_LINE> <INDENT> def __init__(self, pool=1): <NEW_LINE> <INDENT> self.pool = None <NEW_LINE> self._mapfunc = map <NEW_LINE> self._own_pool = False <NEW_LINE> if callable(pool): <NEW_LINE> <INDENT> self.pool = pool <NEW_LINE> self._mapfunc = self.pool <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if int(pool) == -1: <NEW_LINE> <INDENT> self.pool = Pool() <NEW_LINE> self._mapfunc = self.pool.map <NEW_LINE> self._own_pool = True <NEW_LINE> <DEDENT> elif int(pool) == 1: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif int(pool) > 1: <NEW_LINE> <INDENT> self.pool = Pool(processes=int(pool)) <NEW_LINE> self._mapfunc = self.pool.map <NEW_LINE> self._own_pool = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise RuntimeError("Number of workers specified must be -1," " an int >= 1, or an object with a 'map' method") <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> def __del__(self): <NEW_LINE> <INDENT> self.close() <NEW_LINE> self.terminate() <NEW_LINE> <DEDENT> def terminate(self): <NEW_LINE> <INDENT> if self._own_pool: <NEW_LINE> <INDENT> self.pool.terminate() <NEW_LINE> <DEDENT> <DEDENT> def join(self): <NEW_LINE> <INDENT> if self._own_pool: <NEW_LINE> <INDENT> self.pool.join() <NEW_LINE> <DEDENT> <DEDENT> def close(self): <NEW_LINE> <INDENT> if self._own_pool: <NEW_LINE> <INDENT> self.pool.close() <NEW_LINE> <DEDENT> <DEDENT> def __exit__(self, exc_type, exc_value, traceback): <NEW_LINE> <INDENT> if self._own_pool: <NEW_LINE> <INDENT> self.pool.close() <NEW_LINE> self.pool.terminate() <NEW_LINE> <DEDENT> <DEDENT> def __call__(self, func, iterable): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self._mapfunc(func, iterable) <NEW_LINE> <DEDENT> except TypeError as e: <NEW_LINE> <INDENT> raise TypeError("The map-like callable must be of the" " form f(func, iterable)") from e
Parallelisation wrapper for working with map-like callables, such as `multiprocessing.Pool.map`. Parameters ---------- pool : int or map-like callable If `pool` is an integer, then it specifies the number of threads to use for parallelization. If ``int(pool) == 1``, then no parallel processing is used and the map builtin is used. If ``pool == -1``, then the pool will utilize all available CPUs. If `pool` is a map-like callable that follows the same calling sequence as the built-in map function, then this callable is used for parallelization.
62598fa3796e427e5384e61b
class GrpcDebugHook(session_run_hook.SessionRunHook): <NEW_LINE> <INDENT> def __init__(self, grpc_debug_server_addresses, watch_fn=None, thread_name_filter=None, log_usage=True): <NEW_LINE> <INDENT> for address in grpc_debug_server_addresses: <NEW_LINE> <INDENT> if address.startswith(_GRPC_ENDPOINT_PREFIX): <NEW_LINE> <INDENT> raise ValueError( ("Debug server address %r starts with %r. It should not because " "the hook already automatically adds the prefix.") % ( address, _GRPC_ENDPOINT_PREFIX)) <NEW_LINE> <DEDENT> <DEDENT> self._grpc_debug_wrapper_session = None <NEW_LINE> self._thread_name_filter = thread_name_filter <NEW_LINE> self._grpc_debug_server_addresses = grpc_debug_server_addresses <NEW_LINE> self._watch_fn = watch_fn <NEW_LINE> self._log_usage = log_usage <NEW_LINE> <DEDENT> def before_run(self, run_context): <NEW_LINE> <INDENT> if not self._grpc_debug_wrapper_session: <NEW_LINE> <INDENT> self._grpc_debug_wrapper_session = grpc_wrapper.GrpcDebugWrapperSession( run_context.session, self._grpc_debug_server_addresses, watch_fn=self._watch_fn, thread_name_filter=self._thread_name_filter, log_usage=self._log_usage) <NEW_LINE> <DEDENT> fetches = run_context.original_args.fetches <NEW_LINE> feed_dict = run_context.original_args.feed_dict <NEW_LINE> watch_options = self._watch_fn(fetches, feed_dict) <NEW_LINE> run_options = config_pb2.RunOptions() <NEW_LINE> debug_utils.watch_graph( run_options, run_context.session.graph, debug_urls=self._grpc_debug_wrapper_session.prepare_run_debug_urls( fetches, feed_dict), debug_ops=watch_options.debug_ops, node_name_regex_whitelist=watch_options.node_name_regex_whitelist, op_type_regex_whitelist=watch_options.op_type_regex_whitelist, tensor_dtype_regex_whitelist=watch_options.tensor_dtype_regex_whitelist, tolerate_debug_op_creation_failures=( watch_options.tolerate_debug_op_creation_failures)) <NEW_LINE> return session_run_hook.SessionRunArgs( None, feed_dict=None, options=run_options)
A hook that streams debugger-related events to any grpc_debug_server. For example, the debugger data server is a grpc_debug_server. The debugger data server writes debugger-related events it receives via GRPC to logdir. This enables debugging features in Tensorboard such as health pills. When the arguments of debug_utils.watch_graph changes, strongly consider changing arguments here too so that features are available to tflearn users. Can be used as a monitor/hook for `tf.train.MonitoredSession`s and `tf.contrib.learn`'s `Estimator`s and `Experiment`s.
62598fa3236d856c2adc937e
class TestIsVisibleCss: <NEW_LINE> <INDENT> @pytest.fixture(autouse=True) <NEW_LINE> def setup(self, stubs): <NEW_LINE> <INDENT> self.frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100)) <NEW_LINE> <DEDENT> def test_visibility_visible(self): <NEW_LINE> <INDENT> elem = get_webelem(QRect(0, 0, 10, 10), self.frame, visibility='visible') <NEW_LINE> assert elem.is_visible(self.frame) <NEW_LINE> <DEDENT> def test_visibility_hidden(self): <NEW_LINE> <INDENT> elem = get_webelem(QRect(0, 0, 10, 10), self.frame, visibility='hidden') <NEW_LINE> assert not elem.is_visible(self.frame) <NEW_LINE> <DEDENT> def test_display_inline(self): <NEW_LINE> <INDENT> elem = get_webelem(QRect(0, 0, 10, 10), self.frame, display='inline') <NEW_LINE> assert elem.is_visible(self.frame) <NEW_LINE> <DEDENT> def test_display_none(self): <NEW_LINE> <INDENT> elem = get_webelem(QRect(0, 0, 10, 10), self.frame, display='none') <NEW_LINE> assert not elem.is_visible(self.frame)
Tests for is_visible with CSS attributes. Attributes: frame: The FakeWebFrame we're using to test.
62598fa32c8b7c6e89bd364d
class Daughter(Heir): <NEW_LINE> <INDENT> def add(self, calc, mother, father): <NEW_LINE> <INDENT> calc.deceased_set.first().add_daughter(daughter=self, mother=mother, father=father) <NEW_LINE> <DEDENT> def get_quote(self, calc): <NEW_LINE> <INDENT> if calc.has_son(): <NEW_LINE> <INDENT> self.asaba = True <NEW_LINE> self.quote_reason = _("Daughter/s with Son/s share the residuary. The son will receive a share of two daughters.") <NEW_LINE> if calc.heir_set.instance_of(Daughter).count() > 1: <NEW_LINE> <INDENT> self.shared_quote = True <NEW_LINE> <DEDENT> <DEDENT> elif calc.heir_set.instance_of(Daughter).count() == 1: <NEW_LINE> <INDENT> self.quote = 1/2 <NEW_LINE> self.quote_reason = _("Daughter gets 1/2 when she has no other sibling/s") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.quote = 2/3 <NEW_LINE> self.shared_quote = True <NEW_LINE> self.quote_reason = _("Daughters share the quote of 2/3 when there is no son/s") <NEW_LINE> <DEDENT> self.save() <NEW_LINE> return self.quote
Daughter Class
62598fa3adb09d7d5dc0a412
class LuftdatenConnectionError(LuftdatenError): <NEW_LINE> <INDENT> pass
When a connection error is encountered.
62598fa330bbd722464698bb
class get_result: <NEW_LINE> <INDENT> thrift_spec = ( (0, TType.STRUCT, 'success', (Person, Person.thrift_spec), None, ), ) <NEW_LINE> def __init__(self, success=None,): <NEW_LINE> <INDENT> self.success = success <NEW_LINE> <DEDENT> def read(self, iprot): <NEW_LINE> <INDENT> if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) <NEW_LINE> return <NEW_LINE> <DEDENT> iprot.readStructBegin() <NEW_LINE> while True: <NEW_LINE> <INDENT> (fname, ftype, fid) = iprot.readFieldBegin() <NEW_LINE> if ftype == TType.STOP: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if fid == 0: <NEW_LINE> <INDENT> if ftype == TType.STRUCT: <NEW_LINE> <INDENT> self.success = Person() <NEW_LINE> self.success.read(iprot) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> iprot.readFieldEnd() <NEW_LINE> <DEDENT> iprot.readStructEnd() <NEW_LINE> <DEDENT> def write(self, oprot): <NEW_LINE> <INDENT> if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) <NEW_LINE> return <NEW_LINE> <DEDENT> oprot.writeStructBegin('get_result') <NEW_LINE> if self.success is not None: <NEW_LINE> <INDENT> oprot.writeFieldBegin('success', TType.STRUCT, 0) <NEW_LINE> self.success.write(oprot) <NEW_LINE> oprot.writeFieldEnd() <NEW_LINE> <DEDENT> oprot.writeFieldStop() <NEW_LINE> oprot.writeStructEnd() <NEW_LINE> <DEDENT> def validate(self): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> def __hash__(self): <NEW_LINE> <INDENT> value = 17 <NEW_LINE> value = (value * 31) ^ hash(self.success) <NEW_LINE> return value <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> L = ['%s=%r' % (key, value) for key, value in self.__dict__.iteritems()] <NEW_LINE> return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other)
Attributes: - success
62598fa3656771135c48950b
class BigbysHand(Spell): <NEW_LINE> <INDENT> name = "Bigbys Hand" <NEW_LINE> level = 5 <NEW_LINE> casting_time = "1 action" <NEW_LINE> casting_range = "120 feet" <NEW_LINE> components = ('V', 'S', 'M') <NEW_LINE> materials = """An eggshell and a snakeskin glove""" <NEW_LINE> duration = "Instantaneous" <NEW_LINE> ritual = False <NEW_LINE> magic_school = "Evocation" <NEW_LINE> classes = ('Wizard',)
You create a Large hand of shimmering, translucent force in an unoccupied space that you can see within range. The hand lasts for the spell’s duration, and it moves at your command, mimicking the movements of your own hand. The hand is an object that has AC 20 and hit points equal to your hit point maximum. If it drops to 0 hit points, the spell ends. It has a Strength of 26 (+8) and a Dexterity of 10 (+0). The hand doesn’t fill its space. When you cast the spell and as a bonus action on your subsequent turns, you can move the hand up to 60 feet and then cause one of the following effects with it. Clenched Fist  The hand strikes one creature or object within 5 feet of it. Make a melee spell attack for the hand using your game statistics. On a hit, the target takes 4d8 force damage. Forceful Hand The hand attempts to push a creature within 5 feet of it in a direction you choose. Make a check with the hand’s Strength contested by the Strength (Athletics) check of the target. If the target is Medium or smaller, you have advantage on the check. If you succeed, the hand pushes the target up to 5 feet plus a number of feet equal to five times your spellcasting ability modifier. The hand moves with the target to remain within 5 feet of it. Grasping Hand The hand attempts to grapple a Huge or smaller creature within 5 feet of it. You use the hand’s Strength score to resolve the grapple. If the target is Medium or smaller, you have advantage on the check. While the hand is grappling the target, you can use a bonus action to have the hand crush it. When you do so, the target takes bludgeoning damage equal to 2d6 + your spellcasting ability modifier. Interposing Hand The hand interposes itself between you and a creature you choose until you give the hand a different command. The hand moves to stay between you and the target, providing you with half cover against the target. The target can’t move through the hand’s space if its Strength score is less than or equal to the hand’s Strength score. If its Strength score is higher than the hand’s Strength score, the target can move toward you through the hand’s space, but that space is difficult terrain for the target. At Higher Levels: When you cast this spell using a spell slot of 6th level or higher, the damage from the clenched fist option increases by 2d8 and the damage from the grasping hand increases by 2d6 for each slot level above 5th.
62598fa345492302aabfc358
class EvenMask(BinaryMask): <NEW_LINE> <INDENT> def __init__(self, size): <NEW_LINE> <INDENT> super().__init__(size) <NEW_LINE> <DEDENT> def __call__(self): <NEW_LINE> <INDENT> return np.array([1 if i % 2 == 0 else 0 for i in range(self.size)])
1 for even, 0 for odds
62598fa332920d7e50bc5ede
class Graph: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.edges = defaultdict(list) <NEW_LINE> self.distances = {} <NEW_LINE> <DEDENT> def add_edge(self, from_node, to_node, distance): <NEW_LINE> <INDENT> self.edges[from_node].append(to_node) <NEW_LINE> self.distances[(from_node, to_node)] = distance <NEW_LINE> <DEDENT> def dijkstra(self, start, end): <NEW_LINE> <INDENT> if start == end: <NEW_LINE> <INDENT> return float(0) <NEW_LINE> <DEDENT> Q = [] <NEW_LINE> d = {start: 0} <NEW_LINE> Qd = {} <NEW_LINE> previous = {} <NEW_LINE> visited_set = set([start]) <NEW_LINE> adj = self.edges <NEW_LINE> distances = self.distances <NEW_LINE> for neighbour in adj.get(start, []): <NEW_LINE> <INDENT> distance = distances[start, neighbour] <NEW_LINE> item = [distance, start, neighbour] <NEW_LINE> d[neighbour] = distance <NEW_LINE> heapq.heappush(Q, item) <NEW_LINE> Qd[neighbour] = item <NEW_LINE> <DEDENT> while Q: <NEW_LINE> <INDENT> distance, parent, cur = heapq.heappop(Q) <NEW_LINE> if cur not in visited_set: <NEW_LINE> <INDENT> previous[cur] = parent <NEW_LINE> visited_set.add(cur) <NEW_LINE> if cur == end: <NEW_LINE> <INDENT> return d[cur] <NEW_LINE> <DEDENT> for v in adj.get(cur, []): <NEW_LINE> <INDENT> if d.get(v): <NEW_LINE> <INDENT> if d[v] > distances[cur, v] + d[cur]: <NEW_LINE> <INDENT> d[v] = distances[cur, v] + d[cur] <NEW_LINE> Qd[v][0] = d[v] <NEW_LINE> Qd[v][1] = cur <NEW_LINE> heapq._siftdown(Q, 0, Q.index(Qd[v])) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> d[v] = distances[cur, v] + d[cur] <NEW_LINE> item = [d[v], cur, v] <NEW_LINE> heapq.heappush(Q, item) <NEW_LINE> Qd[v] = item <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> return None
data structure to store weighted directed graph in the form of adjecency list
62598fa30c0af96317c56209
class CommunityList(Widget, BaseList): <NEW_LINE> <INDENT> CHILD_ATTRIBUTE = "data"
Class to represent a Related Communities widget. Find an existing one: .. code-block:: python community_list = None widgets = reddit.subreddit('redditdev').widgets for widget in widgets.sidebar: if isinstance(widget, praw.models.CommunityList): community_list = widget break print(community_list) Create one (requires proper moderator permissions): .. code-block:: python widgets = reddit.subreddit('redditdev').widgets styles = {'backgroundColor': '#FFFF66', 'headerColor': '#3333EE'} subreddits = ['learnpython', reddit.subreddit('announcements')] community_list = widgets.mod.add_community_list('Related subreddits', subreddits, styles, 'description') For more information on creation, see :meth:`.add_community_list`. Update one (requires proper moderator permissions): .. code-block:: python new_styles = {'backgroundColor': '#FFFFFF', 'headerColor': '#FF9900'} community_list = community_list.mod.update(shortName='My fav subs', styles=new_styles) Delete one (requires proper moderator permissions): .. code-block:: python community_list.mod.delete() **Typical Attributes** This table describes attributes that typically belong to objects of this class. Since attributes are dynamically provided (see :ref:`determine-available-attributes-of-an-object`), there is not a guarantee that these attributes will always be present, nor is this list comprehensive in any way. ======================= =================================================== Attribute Description ======================= =================================================== ``data`` A ``list`` of :class:`.Subreddit`\ s. These can also be iterated over by iterating over the :class:`.CommunityList` (e.g. ``for sub in community_list``). ``id`` The widget ID. ``kind`` The widget kind (always ``'community-list'``). ``shortName`` The short name of the widget. ``styles`` A ``dict`` with the keys ``'backgroundColor'`` and ``'headerColor'``. ``subreddit`` The :class:`.Subreddit` the button widget belongs to. ======================= ===================================================
62598fa3435de62698e9bc7c
class BucketlistSerializer(serializers.ModelSerializer): <NEW_LINE> <INDENT> items = ItemSerializer(many=True, read_only=True) <NEW_LINE> created_by = CreatedbyField(read_only=True) <NEW_LINE> class Meta: <NEW_LINE> <INDENT> model = Bucketlist <NEW_LINE> fields = ('id', 'name', 'items', 'date_created', 'date_modified', 'created_by') <NEW_LINE> <DEDENT> def create(self, validated_data): <NEW_LINE> <INDENT> request = self.context['request'] <NEW_LINE> created_by = request.user <NEW_LINE> print(request.user) <NEW_LINE> add_to_validated = {'created_by': created_by} <NEW_LINE> data = validated_data.copy() <NEW_LINE> data.update(add_to_validated) <NEW_LINE> return Bucketlist.objects.create(**data)
Model serializer for the bucketlist model
62598fa385dfad0860cbf9b8
class GB3DownstreamUTR(GB3Part, GB3OmegaModule): <NEW_LINE> <INDENT> signature = ("GCTT", "GGTA")
A GoldenBraid 3.0 3' Untranslated Region.
62598fa33317a56b869be48d
class DatasetHistoValues(Dataset): <NEW_LINE> <INDENT> def __init__(self, generator, document): <NEW_LINE> <INDENT> self.generator = generator <NEW_LINE> self.document = document <NEW_LINE> self.linked = None <NEW_LINE> self._invalidpoints = None <NEW_LINE> self.changeset = -1 <NEW_LINE> <DEDENT> def getData(self): <NEW_LINE> <INDENT> if self.changeset != self.generator.document.changeset: <NEW_LINE> <INDENT> self.datacache = self.generator.getBinVals() <NEW_LINE> self.changeset = self.generator.document.changeset <NEW_LINE> <DEDENT> return self.datacache <NEW_LINE> <DEDENT> def saveToFile(self, fileobj, name): <NEW_LINE> <INDENT> self.generator.saveToFile(fileobj) <NEW_LINE> <DEDENT> def linkedInformation(self): <NEW_LINE> <INDENT> return self.generator.linkedInformation() + " (bin values)" <NEW_LINE> <DEDENT> data = property(lambda self: self.getData()[0]) <NEW_LINE> nerr = property(lambda self: self.getData()[1]) <NEW_LINE> perr = property(lambda self: self.getData()[2]) <NEW_LINE> serr = None
A dataset for getting the height of the bins in a histogram.
62598fa366656f66f7d5a279
class PaxosMessage: <NEW_LINE> <INDENT> def __init__(self, msg_type, request_seq): <NEW_LINE> <INDENT> self.msg_type = msg_type <NEW_LINE> self.request_seq = request_seq <NEW_LINE> self.new_block = None <NEW_LINE> self.prop_block = None <NEW_LINE> self.supp_block = None <NEW_LINE> self.com_block = None <NEW_LINE> self.last_committed_block = None <NEW_LINE> <DEDENT> def serialize(self): <NEW_LINE> <INDENT> obj_list = [self.last_committed_block, self.com_block, self.supp_block, self.prop_block, self.new_block, self.request_seq, self.msg_type] <NEW_LINE> obj_bytes = cbor.dumps(obj_list) <NEW_LINE> return b'PAM' + obj_bytes <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def unserialize(msg): <NEW_LINE> <INDENT> obj_list = cbor.loads(msg[3:]) <NEW_LINE> obj = PaxosMessage.__new__(PaxosMessage) <NEW_LINE> setattr(obj, 'msg_type', obj_list.pop()) <NEW_LINE> setattr(obj, 'request_seq', obj_list.pop()) <NEW_LINE> setattr(obj, 'new_block', obj_list.pop()) <NEW_LINE> setattr(obj, 'prop_block', obj_list.pop()) <NEW_LINE> setattr(obj, 'supp_block', obj_list.pop()) <NEW_LINE> setattr(obj, 'com_block', obj_list.pop()) <NEW_LINE> setattr(obj, 'last_committed_block', obj_list.pop()) <NEW_LINE> return obj
A paxos message used to commit a block. Args: msg_type (str): TRY, TRY_OK, PROPOSE, PROPOSE_ACK or COMMIT. request_seq (int): each message contains a request sequence number s.t outdated messaged can be detected. Attributes: new_block (int): block_id of new block (block a quick node wants to commit). prop_block (int): block_id of proposed block. supp_block (int): block_id of support block (supporting the proposed block). com_block (int): block_id of compromise block. last_committed_block (int): block_id of last committed block (for faster recovery in case of partition).
62598fa3e1aae11d1e7ce767
class SessionMiddleware(object): <NEW_LINE> <INDENT> def __init__(self, bugsnag): <NEW_LINE> <INDENT> self.bugsnag = bugsnag <NEW_LINE> <DEDENT> def __call__(self, notification): <NEW_LINE> <INDENT> tls = ThreadLocals.get_instance() <NEW_LINE> session = tls.get_item('bugsnag-session', {}).copy() <NEW_LINE> if session: <NEW_LINE> <INDENT> if notification.unhandled: <NEW_LINE> <INDENT> session['events']['unhandled'] += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> session['events']['handled'] += 1 <NEW_LINE> <DEDENT> notification.session = session <NEW_LINE> <DEDENT> self.bugsnag(notification)
Session middleware ensures that a session is appended to the notification.
62598fa391af0d3eaad39c95
class RNNModel(nn.Module): <NEW_LINE> <INDENT> def __init__(self, rnn_type, ntoken, ninp, nhid, nlayers, dropout=0.5, tie_weights=False): <NEW_LINE> <INDENT> super(RNNModel, self).__init__() <NEW_LINE> print("building RNN language model...") <NEW_LINE> self.drop = nn.Dropout(dropout) <NEW_LINE> self.encoder = nn.Embedding(ntoken, ninp) <NEW_LINE> if rnn_type in ['LSTM', 'GRU']: <NEW_LINE> <INDENT> self.rnn = getattr(nn, rnn_type)(ninp, nhid, nlayers, dropout=dropout) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> nonlinearity = {'RNN_TANH': 'tanh', 'RNN_RELU': 'relu'}[rnn_type] <NEW_LINE> self.rnn = nn.RNN(ninp, nhid, nlayers, nonlinearity=nonlinearity, dropout=dropout) <NEW_LINE> <DEDENT> self.decoder = nn.Linear(nhid, ntoken) <NEW_LINE> if tie_weights: <NEW_LINE> <INDENT> if nhid != ninp: <NEW_LINE> <INDENT> raise ValueError('tied: nhid and emsize must be equal') <NEW_LINE> <DEDENT> self.decoder.weight = self.encoder.weight <NEW_LINE> <DEDENT> self.init_weights() <NEW_LINE> self.rnn_type = rnn_type <NEW_LINE> self.nhid = nhid <NEW_LINE> self.nlayers = nlayers <NEW_LINE> <DEDENT> def init_weights(self): <NEW_LINE> <INDENT> initrange = 0.1 <NEW_LINE> self.encoder.weight.data.uniform_(-initrange, initrange) <NEW_LINE> self.decoder.bias.data.fill_(0) <NEW_LINE> self.decoder.weight.data.uniform_(-initrange, initrange) <NEW_LINE> <DEDENT> def forward(self, input, hidden): <NEW_LINE> <INDENT> emb = self.drop(self.encoder(input)) <NEW_LINE> output, hidden = self.rnn(emb, hidden) <NEW_LINE> output = self.drop(output) <NEW_LINE> decoded = self.decoder(output.view(output.size(0)*output.size(1), output.size(2))) <NEW_LINE> decoded = decoded.view(output.size(0), output.size(1), decoded.size(1)) <NEW_LINE> return decoded, hidden <NEW_LINE> <DEDENT> def init_hidden(self, bsz): <NEW_LINE> <INDENT> weight = next(self.parameters()).data <NEW_LINE> if self.rnn_type == 'LSTM': <NEW_LINE> <INDENT> return (Variable(weight.new(self.nlayers, bsz, self.nhid).zero_()), Variable(weight.new(self.nlayers, bsz, self.nhid).zero_())) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return Variable(weight.new(self.nlayers, bsz, self.nhid).zero_())
Container module with an encoder, a recurrent module, and a decoder.
62598fa399cbb53fe6830d5c
class ProjectionGetTest(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> sim.setup(max_delay=0.5) <NEW_LINE> sim.Population.nPop = 0 <NEW_LINE> self.target33 = sim.Population((3,3), sim.IF_curr_alpha, label="target33") <NEW_LINE> self.target6 = sim.Population((6,), sim.IF_curr_alpha, label="target6") <NEW_LINE> self.source5 = sim.Population((5,), sim.SpikeSourcePoisson, label="source5") <NEW_LINE> self.source22 = sim.Population((2,2), sim.IF_curr_exp, label="source22") <NEW_LINE> self.prjlist = [] <NEW_LINE> self.distrib_Numpy = random.RandomDistribution(rng=random.NumpyRNG(12345), distribution='uniform', parameters=(0.1,0.5)) <NEW_LINE> for tgtP in [self.target6, self.target33]: <NEW_LINE> <INDENT> for srcP in [self.source5, self.source22]: <NEW_LINE> <INDENT> for method in (sim.AllToAllConnector(), sim.FixedProbabilityConnector(p_connect=0.5)): <NEW_LINE> <INDENT> self.prjlist.append(sim.Projection(srcP,tgtP,method)) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> def testGetWeightsWithList(self): <NEW_LINE> <INDENT> for prj in self.prjlist: <NEW_LINE> <INDENT> weights_in = self.distrib_Numpy.next(len(prj)) <NEW_LINE> prj.setWeights(weights_in) <NEW_LINE> weights_out = numpy.array(prj.getWeights(format='list')) <NEW_LINE> assert_arrays_almost_equal(weights_in, weights_out, 1e-7) <NEW_LINE> <DEDENT> <DEDENT> def testGetWeightsWithArray(self): <NEW_LINE> <INDENT> for prj in self.prjlist: <NEW_LINE> <INDENT> weights_in = self.distrib_Numpy.next(len(prj)) <NEW_LINE> prj.setWeights(weights_in) <NEW_LINE> weights_out = numpy.array(prj.getWeights(format='array')).flatten() <NEW_LINE> weights_out = weights_out.compress(weights_out>0) <NEW_LINE> if weights_out.size > 0: <NEW_LINE> <INDENT> self.assertEqual(weights_out[0], prj.connections[0].weight) <NEW_LINE> <DEDENT> self.assertEqual(weights_in.shape, weights_out.shape) <NEW_LINE> assert_arrays_almost_equal(weights_in, weights_out, 1e-7)
Tests of the getWeights(), getDelays() methods of the Projection class.
62598fa3be383301e0253680
class DescribePlayErrorCodeDetailInfoListRequest(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.StartTime = None <NEW_LINE> self.EndTime = None <NEW_LINE> self.Granularity = None <NEW_LINE> self.StatType = None <NEW_LINE> self.PlayDomains = None <NEW_LINE> self.MainlandOrOversea = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> self.StartTime = params.get("StartTime") <NEW_LINE> self.EndTime = params.get("EndTime") <NEW_LINE> self.Granularity = params.get("Granularity") <NEW_LINE> self.StatType = params.get("StatType") <NEW_LINE> self.PlayDomains = params.get("PlayDomains") <NEW_LINE> self.MainlandOrOversea = params.get("MainlandOrOversea")
DescribePlayErrorCodeDetailInfoList request structure.
62598fa37047854f4633f261
class TestGenerate(TestCase): <NEW_LINE> <INDENT> generated_files = ('django-partial.po', 'djangojs-partial.po', 'mako.po') <NEW_LINE> @classmethod <NEW_LINE> def setUpClass(cls): <NEW_LINE> <INDENT> sys.stderr.write( "\nThis test tests that i18n extraction (`paver i18n_extract`) works properly. " "If you experience failures, please check that all instances of `gettext` and " "`ngettext` are used correctly. You can also try running `paver i18n_extract -v` " "locally for more detail.\n" ) <NEW_LINE> sys.stderr.write( "\nExtracting i18n strings and generating dummy translations; " "this may take a few minutes\n" ) <NEW_LINE> sys.stderr.flush() <NEW_LINE> extract.main(verbosity=0) <NEW_LINE> dummy.main(verbosity=0) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def tearDownClass(cls): <NEW_LINE> <INDENT> cmd = "git checkout conf/locale/eo" <NEW_LINE> sys.stderr.write("Cleaning up eo: " + cmd) <NEW_LINE> sys.stderr.flush() <NEW_LINE> returncode = subprocess.call(cmd, shell=True) <NEW_LINE> assert returncode == 0 <NEW_LINE> super(TestGenerate, cls).tearDownClass() <NEW_LINE> <DEDENT> def setUp(self): <NEW_LINE> <INDENT> self.start_time = datetime.now(UTC) - timedelta(seconds=1) <NEW_LINE> <DEDENT> def test_merge(self): <NEW_LINE> <INDENT> filename = os.path.join(CONFIGURATION.source_messages_dir, random_name()) <NEW_LINE> generate.merge(CONFIGURATION.source_locale, target=filename) <NEW_LINE> self.assertTrue(os.path.exists(filename)) <NEW_LINE> os.remove(filename) <NEW_LINE> <DEDENT> @patch.object(CONFIGURATION, 'dummy_locales', ['fake2']) <NEW_LINE> def test_main(self): <NEW_LINE> <INDENT> generate.main(verbosity=0, strict=False) <NEW_LINE> for locale in CONFIGURATION.translated_locales: <NEW_LINE> <INDENT> for filename in ('django', 'djangojs'): <NEW_LINE> <INDENT> mofile = filename + '.mo' <NEW_LINE> path = os.path.join(CONFIGURATION.get_messages_dir(locale), mofile) <NEW_LINE> exists = os.path.exists(path) <NEW_LINE> self.assertTrue(exists, msg='Missing file in locale %s: %s' % (locale, mofile)) <NEW_LINE> self.assertTrue( datetime.fromtimestamp(os.path.getmtime(path), UTC) >= self.start_time, msg='File not recently modified: %s' % path ) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def assert_merge_headers(self, locale): <NEW_LINE> <INDENT> path = os.path.join(CONFIGURATION.get_messages_dir(locale), 'django.po') <NEW_LINE> pof = pofile(path) <NEW_LINE> pattern = re.compile('^#-#-#-#-#', re.M) <NEW_LINE> match = pattern.findall(pof.header) <NEW_LINE> self.assertEqual( len(match), 3, msg="Found %s (should be 3) merge comments in the header for %s" % (len(match), path) )
Tests functionality of i18n/generate.py
62598fa33539df3088ecc13d
class _CatCubeMeans(_BaseCubeMeans): <NEW_LINE> <INDENT> @lazyproperty <NEW_LINE> def means(self): <NEW_LINE> <INDENT> return self._means
Means cube-measure for a non-MR stripe.
62598fa3498bea3a75a579ab
class Bottom_Method(object): <NEW_LINE> <INDENT> def __init__(self, driver): <NEW_LINE> <INDENT> self.driver = driver <NEW_LINE> <DEDENT> def find_elem_in_dom(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.presence_of_element_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('find_elem_in_dom获取 %s 元素超时' % locator) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def find_elems_in_dom(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.presence_of_all_elements_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('find_elems_in_dom获取 %s 元素组超时' % locator) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def find_elem_is_visible(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('find_elem_is_visible获取 %s 元素超时' % locator) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def find_elems_is_visible(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.visibility_of_all_elements_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('find_elems_is_visible获取 %s 元素组超时' % locator) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def find_elem_is_clickable(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.element_to_be_clickable((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('find_elem_is_clickable获取 %s 元素超时' % locator) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def wait_elem_is_visible(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('5秒内 %s 元素仍为可见' % locator) <NEW_LINE> <DEDENT> <DEDENT> def wait_elem_is_display(self, locator, timeout=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> WebDriverWait(self.driver, timeout).until_not( EC.visibility_of_element_located((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('5秒内 %s 元素仍未消失' % locator) <NEW_LINE> <DEDENT> <DEDENT> def find_alert(self, locator, timeout=3): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return WebDriverWait(self.driver, timeout).until( EC.alert_is_present()) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('3秒内没有alert出现') <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def is_and_switch_to_iframe(self, locator, timeout=3): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> WebDriverWait(self.driver, timeout).until( EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, locator))) <NEW_LINE> <DEDENT> except TimeoutException: <NEW_LINE> <INDENT> print('无法切到 %s ifarme' % locator) <NEW_LINE> <DEDENT> <DEDENT> def scroll_to_visiable_element(self, locator): <NEW_LINE> <INDENT> element = self.find_elem_is_visible(locator) <NEW_LINE> self.driver.execute_script("arguments[0].scrollIntoView();", element)
底层方法封装
62598fa3e5267d203ee6b795