Python past.builtins.long() Examples
The following are 30
code examples of past.builtins.long().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
past.builtins
, or try the search function
.
Example #1
Source File: test_state.py From openhtf with Apache License 2.0 | 6 votes |
def __init__(self, *args, **kwargs): super(PhaseState, self).__init__(*args, **kwargs) for m in six.itervalues(self.measurements): # Using functools.partial to capture the value of the loop variable. m.set_notification_callback(functools.partial(self._notify, m.name)) self._cached = { 'name': self.name, 'codeinfo': data.convert_to_base_types(self.phase_record.codeinfo), 'descriptor_id': data.convert_to_base_types( self.phase_record.descriptor_id), # Options are not set until the phase is finished. 'options': None, 'measurements': { k: m.as_base_types() for k, m in six.iteritems(self.measurements)}, 'attachments': {}, 'start_time_millis': long(self.phase_record.record_start_time()), }
Example #2
Source File: handleclient_read_patched_unit_test.py From B2HANDLE with Apache License 2.0 | 6 votes |
def test_get_value_from_handle_HS_ADMIN(self): """Test retrieving an HS_ADMIN value from a handle record.""" handlerecord = RECORD handle = handlerecord['handle'] val = self.inst.get_value_from_handle(handle, 'HS_ADMIN', handlerecord) self.assertIn('handle', val, 'The HS_ADMIN has no entry "handle".') self.assertIn('index', val, 'The HS_ADMIN has no entry "index".') self.assertIn('permissions', val, 'The HS_ADMIN has no entry "permissions".') syntax_ok = check_handle_syntax(val['handle']) self.assertTrue(syntax_ok, 'The handle in HS_ADMIN is not well-formatted.') self.assertIsInstance(val['index'], (int, long), 'The index of the HS_ADMIN is not an integer.') self.assertEqual(str(val['permissions']).replace('0','').replace('1',''), '', 'The permission value in the HS_ADMIN contains not just 0 and 1.')
Example #3
Source File: binary.py From barf-project with BSD 2-Clause "Simplified" License | 6 votes |
def __getitem__(self, key): # TODO: Return bytearray or byte instead of str. if isinstance(key, slice): chunk = bytearray() step = 1 if key.step is None else key.step try: # Read memory one byte at a time. for addr in range(key.start, key.stop, step): chunk.append(self._read_byte(addr)) except IndexError: logger.warn("Address out of range: {:#x}".format(addr)) raise InvalidAddressError() return chunk elif isinstance(key, int) or isinstance(key, long): return self._read_byte(key) else: raise TypeError("Invalid argument type: {}".format(type(key)))
Example #4
Source File: detect.py From roca with MIT License | 6 votes |
def format_pgp_key(key): """ Formats PGP key in 16hex digits :param key: :return: """ if key is None: return None if isinstance(key, (int, long)): return '%016x' % key elif isinstance(key, list): return [format_pgp_key(x) for x in key] else: key = key.strip() key = strip_hex_prefix(key) return format_pgp_key(int(key, 16))
Example #5
Source File: arm.py From barf-project with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, immediate, size=None): super(ArmImmediateOperand, self).__init__("") self._base_hex = True if type(immediate) == str: immediate = immediate.replace("#", "") if '0x' in immediate: immediate = int(immediate, 16) else: immediate = int(immediate) self._base_hex = False assert type(immediate) in [int, long], "Invalid immediate value type." self._immediate = immediate self._size = size
Example #6
Source File: quark_runtime.py From quark with Apache License 2.0 | 5 votes |
def getNumber(self): if isinstance(self.value, (int, long, float)): return self.value else: return None
Example #7
Source File: encoder.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def _can_handle_val(self, v): if isinstance(v, (str, unicode)): return True elif isinstance(v, bool): return True elif isinstance(v, (int, long)): return True elif isinstance(v, float): return True return False
Example #8
Source File: encoder.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def _handle_attr(self, layer, feature, props): for k, v in props.items(): if self._can_handle_attr(k, v): if not PY3 and isinstance(k, str): k = k.decode('utf-8') if k not in self.seen_keys_idx: layer.keys.append(k) self.seen_keys_idx[k] = self.key_idx self.key_idx += 1 feature.tags.append(self.seen_keys_idx[k]) if v not in self.seen_values_idx: self.seen_values_idx[v] = self.val_idx self.val_idx += 1 val = layer.values.add() if isinstance(v, bool): val.bool_value = v elif isinstance(v, str): if PY3: val.string_value = v else: val.string_value = unicode(v, 'utf-8') elif isinstance(v, unicode): val.string_value = v elif isinstance(v, (int, long)): val.int_value = v elif isinstance(v, float): val.double_value = v feature.tags.append(self.seen_values_idx[v])
Example #9
Source File: message.py From canari3 with GNU General Public License v3.0 | 5 votes |
def __get__(self, obj, objtype): if obj is None: return self l = super(LongEntityField, self).__get__(obj, objtype) try: return long(l) if l is not None else None except ValueError: raise ValidationError(self.get_error_msg(self.display_name or self.name, l))
Example #10
Source File: quark_threaded_runtime.py From quark with Apache License 2.0 | 5 votes |
def now(self): return long(time.time() * 1000)
Example #11
Source File: quark_runtime.py From quark with Apache License 2.0 | 5 votes |
def getType(self): if isinstance(self.value, dict): return 'object' elif isinstance(self.value, (list, tuple)): return 'list' elif isinstance(self.value, (str, unicode)): return 'string' elif isinstance(self.value, (int,float,long)): return 'number' elif isinstance(self.value, bool): return 'bool' elif self.value is None: return 'null' else: raise TypeError("Unknown JSONObject type " + str(type(self.value)))
Example #12
Source File: altbn128.py From solcrypto with GNU General Public License v3.0 | 5 votes |
def hashtopoint(x): assert isinstance(x, long) x = x % curve_order while True: beta, y = evalcurve(x) if beta == mulmodp(y, y): assert isoncurve(x, y) return FQ(x), FQ(y) x = addmodn(x, 1)
Example #13
Source File: quark_runtime.py From quark with Apache License 2.0 | 5 votes |
def isNumber(self): return isinstance(self.value, (int, long, float))
Example #14
Source File: quark_runtime.py From quark with Apache License 2.0 | 5 votes |
def _order(self, packer): self.packer = packer self._b = self.packer.byte self._h = self.packer.short self._i = self.packer.int self._q = self.packer.long self._d = self.packer.float
Example #15
Source File: test_connect_api.py From rfapi-python with Apache License 2.0 | 5 votes |
def test_domain_search(self): client = ConnectApiClient() resp = client.search_domains() self.assertIsInstance(resp, ConnectApiResponse) self.assertIsInstance(resp.entities, types.GeneratorType) first_entity = next(resp.entities) self.assertIsInstance(first_entity, DotAccessDict) self.assertEquals(first_entity.id, first_entity.entity.id) self.assertIsInstance(resp.returned_count, int) self.assertIsInstance(resp.total_count, long) self.assertGreater(resp.returned_count, 0)
Example #16
Source File: processors.py From SACN with MIT License | 5 votes |
def process(self, sample, inp_type): if self.successive_for_loops_to_tokens == None: i = 0 level = sample while not ( isinstance(level, basestring) or isinstance(level, long)): level = level[0] i+=1 self.successive_for_loops_to_tokens = i if self.successive_for_loops_to_tokens == 0: ret = self.process_token(sample, inp_type) elif self.successive_for_loops_to_tokens == 1: new_tokens = [] for token in sample: new_tokens.append(self.process_token(token, inp_type)) ret = new_tokens elif self.successive_for_loops_to_tokens == 2: new_sents = [] for sent in sample: new_tokens = [] for token in sent: new_tokens.append(self.process_token(token, inp_type)) new_sents.append(new_tokens) ret = new_sents return ret
Example #17
Source File: processors.py From CPL with MIT License | 5 votes |
def process(self, sample, inp_type): if self.successive_for_loops_to_tokens == None: i = 0 level = sample while not ( isinstance(level, basestring) or isinstance(level, long)): level = level[0] i+=1 self.successive_for_loops_to_tokens = i if self.successive_for_loops_to_tokens == 0: ret = self.process_token(sample, inp_type) elif self.successive_for_loops_to_tokens == 1: new_tokens = [] for token in sample: new_tokens.append(self.process_token(token, inp_type)) ret = new_tokens elif self.successive_for_loops_to_tokens == 2: new_sents = [] for sent in sample: new_tokens = [] for token in sent: new_tokens.append(self.process_token(token, inp_type)) new_sents.append(new_tokens) ret = new_sents return ret
Example #18
Source File: test_encoder.py From mapbox-vector-tile with MIT License | 5 votes |
def test_encode_property_long(self): geometry = 'POINT(0 0)' properties = { 'test_int': int(1), 'test_long': long(1) } self.assertRoundTrip( input_geometry=geometry, expected_geometry={'type': 'Point', 'coordinates': [0, 0]}, properties=properties)
Example #19
Source File: encoder.py From mapbox-vector-tile with MIT License | 5 votes |
def _handle_attr(self, layer, feature, props): for k, v in props.items(): if self._can_handle_attr(k, v): if not PY3 and isinstance(k, str): k = k.decode('utf-8') if k not in self.seen_keys_idx: layer.keys.append(k) self.seen_keys_idx[k] = self.key_idx self.key_idx += 1 feature.tags.append(self.seen_keys_idx[k]) if isinstance(v, bool): values_idx = self.seen_values_bool_idx else: values_idx = self.seen_values_idx if v not in values_idx: values_idx[v] = self.val_idx self.val_idx += 1 val = layer.values.add() if isinstance(v, bool): val.bool_value = v elif isinstance(v, str): if PY3: val.string_value = v else: val.string_value = unicode(v, 'utf-8') elif isinstance(v, unicode): val.string_value = v elif isinstance(v, (int, long)): val.int_value = v elif isinstance(v, float): val.double_value = v feature.tags.append(values_idx[v])
Example #20
Source File: encoder.py From mapbox-vector-tile with MIT License | 5 votes |
def _can_handle_val(self, v): if isinstance(v, (str, unicode)): return True elif isinstance(v, bool): return True elif isinstance(v, (int, long)): return True elif isinstance(v, float): return True return False
Example #21
Source File: smtsymbol.py From barf-project with BSD 2-Clause "Simplified" License | 5 votes |
def _cast_to_bitvec(value, size): if type(value) in (int, long): value = Constant(size, value) assert type(value) in (Constant, BitVec) and value.size == size return value
Example #22
Source File: x86.py From barf-project with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, immediate, size=None): super(X86ImmediateOperand, self).__init__("") assert type(immediate) in [int, long], "Invalid immediate value type." self._immediate = immediate self._size = size
Example #23
Source File: arm.py From barf-project with BSD 2-Clause "Simplified" License | 5 votes |
def max_instruction_size(self): """Return the maximum instruction size in bytes. """ instruction_size_map = { ARCH_ARM_MODE_ARM: 4, # NOTE: THUMB instructions are 2 byte long but THUMBv2 # instruction have both 2 and 4 byte long. ARCH_ARM_MODE_THUMB: 4, } return instruction_size_map[self._arch_mode]
Example #24
Source File: detect.py From roca with MIT License | 5 votes |
def process_js_mod(self, data, name, idx, sub_idx): """ Processes one moduli from JSON :param data: :param name: :param idx: :param sub_idx: :return: """ if isinstance(data, (int, long)): js = collections.OrderedDict() js['type'] = 'js-mod-num' js['fname'] = name js['idx'] = idx js['sub_idx'] = sub_idx js['n'] = '0x%x' % data if self.has_fingerprint(data): logger.warning('Fingerprint found in json int modulus %s idx %s %s' % (name, idx, sub_idx)) self.mark_and_add_effort(data, js) if self.do_print: print(json.dumps(js)) return TestResult(js) self.process_mod_line(data, name, idx, aux={'stype': 'json', 'sub_idx': sub_idx})
Example #25
Source File: keys.py From ivre with GNU General Public License v3.0 | 5 votes |
def getkeys(self, host): for script in self.getscripts(host): for cert in script["script"].get(self.scriptid, []): key = cert['pubkey'] yield Key(host['addr'], script["port"], "ssl", key['type'], key['bits'], _rsa_construct(long(key['exponent']), long(key['modulus'])), utils.decode_hex(cert['md5']))
Example #26
Source File: keys.py From ivre with GNU General Public License v3.0 | 5 votes |
def data2key(data): data = utils._parse_ssh_key(data) _, exp, mod = (next(data), # noqa: F841 (_) long(utils.encode_hex(next(data)), 16), long(utils.encode_hex(next(data)), 16)) return _rsa_construct(exp, mod)
Example #27
Source File: keys.py From ivre with GNU General Public License v3.0 | 5 votes |
def pem2key(cls, pem): certtext = cls._pem2key(pem) return None if certtext is None else _rsa_construct( long(certtext['exponent']), long(cls.modulus_badchars.sub(b"", certtext['modulus']), 16), )
Example #28
Source File: keys.py From ivre with GNU General Public License v3.0 | 5 votes |
def getkeys(self, record): yield Key(record['addr'], record["port"], "ssh", record['infos']['algo'][4:], record['infos']['bits'], _rsa_construct(long(record['infos']['exponent']), long(record['infos']['modulus'])), utils.decode_hex(record['infos']['md5']))
Example #29
Source File: keys.py From ivre with GNU General Public License v3.0 | 5 votes |
def getkeys(self, record): certtext = self._der2key(record['value']) if certtext is None: return yield Key(record['addr'], record["port"], "ssl", certtext['type'], int(certtext['len']), _rsa_construct(long(certtext['exponent']), long(self.modulus_badchars.sub( b"", certtext['modulus'] ), 16)), utils.decode_hex(record['infos']['md5']))
Example #30
Source File: merkle.py From solcrypto with GNU General Public License v3.0 | 5 votes |
def serialize(v): if isinstance(v, str): return v if isinstance(v, (int, long)): return zpad(int_to_big_endian(v), 32) raise NotImplementedError(v)