Python uuid.uuid3() Examples

The following are 30 code examples of uuid.uuid3(). 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 uuid , or try the search function .
Example #1
Source File: method.py    From neo-boa with MIT License 8 votes vote down vote up
def __init__(self, module, block, module_name, extra):
        self.module = module
        self.block = block
        self.module_name = module_name
        self._extra = extra

        method_block_index = self.get_code_block_index(self.block)
        if method_block_index is None:
            raise Exception('Block of code of a method from %s module was not found', self.module_name)

        self.name = self.block[method_block_index + 1].arg
        self._id = uuid3(UUID('{baa187e0-2c51-4ef6-aa42-b3421c22d5e1}'), self.full_name)
        self.start_line_no = self.block[method_block_index].lineno
        self.code_object = self.block[method_block_index].arg

#        dis.dis(code_object)
        self.code, self.dictionary_defs = preprocess_method_body(self.code_object)

        self.bytecode = Bytecode.from_code(self.code)

        self.evaluate_annotations(method_block_index)
        self.setup() 
Example #2
Source File: test_uuid.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #3
Source File: test_uuid.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #4
Source File: test_uuid.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #5
Source File: test_uuid.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #6
Source File: test_uuid.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #7
Source File: test_uuid.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #8
Source File: volatile.py    From scapy with GNU General Public License v2.0 6 votes vote down vote up
def _fix(self):
        if self.uuid_template:
            return uuid.UUID(("%08x%04x%04x" + ("%02x" * 8))
                             % self.uuid_template)
        elif self.version == 1:
            return uuid.uuid1(self.node, self.clock_seq)
        elif self.version == 3:
            return uuid.uuid3(self.namespace, self.name)
        elif self.version == 4:
            return uuid.uuid4()
        elif self.version == 5:
            return uuid.uuid5(self.namespace, self.name)
        else:
            raise ValueError("Unhandled version")


# Automatic timestamp 
Example #9
Source File: test_uuid.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #10
Source File: test_uuid.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #11
Source File: test_uuid.py    From BinderFilter with MIT License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #12
Source File: test_uuid.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #13
Source File: manager.py    From cyborg with Apache License 2.0 5 votes vote down vote up
def get_rp_uuid_from_obj(self, obj):
        return str(uuid.uuid3(uuid.NAMESPACE_DNS, six.ensure_str(obj.name))) 
Example #14
Source File: local.py    From cate with MIT License 5 votes vote down vote up
def generate_uuid(cls, ref_id: str,
                      time_range: Optional[TimeRange] = None,
                      region: Optional[shapely.geometry.Polygon] = None,
                      var_names: Optional[VarNames] = None) -> str:

        if time_range:
            ref_id += TimeRangeLike.format(time_range)
        if region:
            ref_id += PolygonLike.format(region)
        if var_names:
            ref_id += VarNamesLike.format(var_names)

        return str(uuid.uuid3(_NAMESPACE, ref_id)) 
Example #15
Source File: manager.py    From cyborg with Apache License 2.0 5 votes vote down vote up
def _get_sub_provider(self, context, parent, name):
        old_sub_pr_uuid = str(uuid.uuid3(uuid.NAMESPACE_DNS,
                                         six.ensure_str(name)))
        new_sub_pr_uuid = self.placement_client.ensure_resource_provider(
            context, old_sub_pr_uuid,
            name=name, parent_provider_uuid=parent)
        if old_sub_pr_uuid == new_sub_pr_uuid:
            return new_sub_pr_uuid
        else:
            raise exception.Conflict() 
Example #16
Source File: test_types.py    From pydantic with MIT License 5 votes vote down vote up
def test_uuid_validation():
    a = uuid.uuid1()
    b = uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
    c = uuid.uuid4()
    d = uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')

    m = UUIDModel(a=a, b=b, c=c, d=d)
    assert m.dict() == {'a': a, 'b': b, 'c': c, 'd': d}

    with pytest.raises(ValidationError) as exc_info:
        UUIDModel(a=d, b=c, c=b, d=a)
    assert exc_info.value.errors() == [
        {
            'loc': ('a',),
            'msg': 'uuid version 1 expected',
            'type': 'value_error.uuid.version',
            'ctx': {'required_version': 1},
        },
        {
            'loc': ('b',),
            'msg': 'uuid version 3 expected',
            'type': 'value_error.uuid.version',
            'ctx': {'required_version': 3},
        },
        {
            'loc': ('c',),
            'msg': 'uuid version 4 expected',
            'type': 'value_error.uuid.version',
            'ctx': {'required_version': 4},
        },
        {
            'loc': ('d',),
            'msg': 'uuid version 5 expected',
            'type': 'value_error.uuid.version',
            'ctx': {'required_version': 5},
        },
    ] 
Example #17
Source File: 0118_remove_standardpage_intro_and_body.py    From wagtail-torchbox with MIT License 5 votes vote down vote up
def update_revisions(page, content):
    streamfield_json = content.get('streamfield', '')

    if streamfield_json:
        streamfield = json.loads(streamfield_json)
    else:
        streamfield = []

    # Append body to beginning of streamfield
    if content['body'] not in ['', '<p></p>', '<p><br/></p>']:
        content['old_body'] = content['body']

        streamfield.insert(0, {
            "type": "paragraph",
            "value": content['body'],
            "id": str(uuid3(UUID_NAMESPACE, content['body'])),
        })

    # Append intro to beginning of streamfield
    if content['intro'] not in ['', '<p></p>', '<p><br/></p>']:
        streamfield.insert(0, {
            "type": "paragraph",
            "value": content['intro'],
            "id": str(uuid3(UUID_NAMESPACE, content['intro'])),
        })

    # Save streamfield content with "body" key, as it was renamed as well in this migration
    content['body'] = json.dumps(streamfield)

    return content 
Example #18
Source File: 0118_remove_standardpage_intro_and_body.py    From wagtail-torchbox with MIT License 5 votes vote down vote up
def migrate_standardpage_intro_and_body_to_streamfield(apps, schema_editor):
    StandardPage = apps.get_model('torchbox.StandardPage')
    stream_block = StandardPage._meta.get_field('streamfield').stream_block

    # Append body to beginning of streamfield
    for page in StandardPage.objects.exclude(body__in=['', '<p></p>', '<p><br/></p>']):
        # Add body as first block so it appears in the same place on the template
        page.streamfield = StreamValue(
            stream_block,
            [
                ('paragraph', RichText(page.body), str(uuid3(UUID_NAMESPACE, page.body))),
            ] + [
                (child.block_type, child.value, child.id)
                for child in page.streamfield
            ]
        )

        page.save()

    # Append intro to beginning of streamfield
    for page in StandardPage.objects.exclude(intro__in=['', '<p></p>', '<p><br/></p>']):
        # Add intro as first block so it appears in the same place on the template
        page.streamfield = StreamValue(
            stream_block,
            [
                ('paragraph', RichText(page.intro), str(uuid3(UUID_NAMESPACE, page.intro))),
            ] + [
                (child.block_type, child.value, child.id)
                for child in page.streamfield
            ]
        )

        page.save() 
Example #19
Source File: tools.py    From fp-server with MIT License 5 votes vote down vote up
def get_uuid3(str_in):
    """ make a UUID using an MD5 hash of a namespace UUID and a name
    @param str_in 输入字符串
    """
    s = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)

    return str(s) 
Example #20
Source File: test_archiver.py    From qiime2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_parse_uuid_invalid(self):
        # Invalid uuid4 taken from https://gist.github.com/ShawnMilo/7777304
        uuid_str = '89eb3586-8a82-47a4-c911-758a62601cf7'
        self.assertFalse(_ZipArchive._is_uuid4(uuid_str))

        # Not a UUID.
        uuid_str = 'abc123'
        self.assertFalse(_ZipArchive._is_uuid4(uuid_str))

        # Other UUID versions.
        for uuid_ in (uuid.uuid1(), uuid.uuid3(uuid.NAMESPACE_DNS, 'foo'),
                      uuid.uuid5(uuid.NAMESPACE_DNS, 'bar')):
            uuid_str = str(uuid_)
            self.assertFalse(_ZipArchive._is_uuid4(uuid_str)) 
Example #21
Source File: test_random.py    From cadence-python with MIT License 5 votes vote down vote up
def test_python_uuid3_determinism():
    assert uuid.uuid3(uuid.UUID("8d3149e9-71d3-4ad3-9216-bfbf0473b7c6"), "25") == uuid.UUID('db602869-db61-341b-9e01-81393de6c9b0') 
Example #22
Source File: app.py    From datmo with MIT License 5 votes vote down vote up
def generate_hash():
    string_to_hash = str(request.args.get('string_to_hash'))
    hash = str(uuid.uuid3(uuid.NAMESPACE_DNS, string_to_hash))
    return jsonify({"result": hash}) 
Example #23
Source File: accesstoken.py    From mltshp with Mozilla Public License 2.0 5 votes vote down vote up
def generate(authorization_id):
        """
        Generate an access token based on an (unexpired) authorization id.
        """
        auth = authorizationcode.Authorizationcode.get('id=%s', authorization_id)
        consumer_key = uuid.uuid3(uuid.NAMESPACE_DNS, base36encode(auth.id) + '-' + base36encode(auth.app_id))
        consumer_secret = sha224("%s%s" % (str(uuid.uuid1()), time.time())).hexdigest()

        if auth.expires_at > datetime.utcnow():
            access_token = Accesstoken(user_id=auth.user_id, app_id=auth.app_id, consumer_key=str(consumer_key), consumer_secret=str(consumer_secret))
            access_token.save()
            return access_token
        else:
            return None 
Example #24
Source File: lockdown.py    From pymobiledevice with GNU General Public License v3.0 5 votes vote down vote up
def generate_hostID(self):
        hostname = platform.node()
        hostid = uuid.uuid3(uuid.NAMESPACE_DNS, hostname)
        return str(hostid).upper() 
Example #25
Source File: decision_loop.py    From cadence-python with MIT License 5 votes vote down vote up
def random_uuid(self) -> uuid.UUID:
        return uuid.uuid3(uuid.UUID(self.current_run_id), str(self.decider.get_and_increment_next_id())) 
Example #26
Source File: registration.py    From ahenk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def generate_uuid(self, depend_mac=True):
        if depend_mac is False:
            self.logger.debug('uuid creating randomly')
            return uuid.uuid4()  # make a random UUID
        else:
            self.logger.debug('uuid creating according to mac address')
            return uuid.uuid3(uuid.NAMESPACE_DNS,
                              str(get_mac()))  # make a UUID using an MD5 hash of a namespace UUID and a mac address 
Example #27
Source File: test_format_validators.py    From flex with MIT License 5 votes vote down vote up
def test_uuid3_matches():
    for _ in range(100):
        uuid_format_validator(str(uuid.uuid3(uuid.uuid4(), 'test-4')))
        uuid_format_validator(str(uuid.uuid3(uuid.uuid1(), 'test-1'))) 
Example #28
Source File: connection.py    From python-mysql-pool with MIT License 5 votes vote down vote up
def _fabric_server_uuid(host, port):
    """Create a UUID using host and port"""
    return uuid.uuid3(uuid.NAMESPACE_URL, _fabric_xmlrpc_uri(host, port)) 
Example #29
Source File: cgishell.py    From CGIShell with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, url):
        self.fullurl = self._complete_url(url)
        uinfo = urlparse.urlparse(self.fullurl)
        pext = os.path.splitext(uinfo.path)
        if len(pext) == 2 and pext[1] not in ('.cgi', '.sh'):
            warnings.warn("Recommended suffix CGI!")

        self.host = uinfo.hostname
        self.uuid = uuid.uuid3(uuid.NAMESPACE_DNS, 'hanchen.me').hex
        self.user = 'unknown'
        self._init_opener() 
Example #30
Source File: tools.py    From thenextquant with MIT License 5 votes vote down vote up
def get_uuid3(str_in):
    """ make a UUID using an MD5 hash of a namespace UUID and a name
    @param str_in 输入字符串
    """
    s = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
    return str(s)