Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-shortuuid for
openSUSE:Factory checked in at 2022-01-10 23:53:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-shortuuid (Old)
and /work/SRC/openSUSE:Factory/.python-shortuuid.new.1892 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-shortuuid"
Mon Jan 10 23:53:03 2022 rev:4 rq:945231 version:1.0.8
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-shortuuid/python-shortuuid.changes
2020-03-19 19:53:48.220276632 +0100
+++
/work/SRC/openSUSE:Factory/.python-shortuuid.new.1892/python-shortuuid.changes
2022-01-10 23:53:11.824782972 +0100
@@ -1,0 +2,22 @@
+Sun Jan 9 02:02:33 UTC 2022 - John Vandenberg <[email protected]>
+
+- Remove tests from runtime package
+- Update to v1.0.8
+ * Include the COPYING file in releases
+- from v1.0.7
+ * Add prefix and max_length to the Django field
+- from v1.0.6
+ * Fix compatibility for python versions older than 3.8
+- from v1.0.5
+ * Don't try to get the version from the pyproject.toml
+ * Fix slow loading times from using pkg_resources
+- from v1.0.4
+ * Fix the cli interface that the previous release broke
+- from v1.0.3
+ * Add Django ShortUUIDField
+- from v1.0.2
+ * Added basic input type validation to encode and decode
+ * Use sys.version_info since sys.version returns string that
+ interprets 3.10 as 3.1 in comparison
+
+-------------------------------------------------------------------
Old:
----
shortuuid-1.0.1.tar.gz
New:
----
shortuuid-1.0.8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-shortuuid.spec ++++++
--- /var/tmp/diff_new_pack.WJCn0w/_old 2022-01-10 23:53:13.036784034 +0100
+++ /var/tmp/diff_new_pack.WJCn0w/_new 2022-01-10 23:53:13.040784038 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-shortuuid
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-shortuuid
-Version: 1.0.1
+Version: 1.0.8
Release: 0
Summary: A generator library for concise, unambiguous and URL-safe UUIDs
License: BSD-3-Clause
@@ -30,6 +30,9 @@
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires(post): update-alternatives
+Requires(postun):update-alternatives
+Requires: python-base
BuildArch: noarch
%python_subpackages
@@ -46,14 +49,24 @@
%install
%python_install
-%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%python_clone -a %{buildroot}%{_bindir}/shortuuid
+%{python_expand rm %{buildroot}%{$python_sitelib}/shortuuid/tests.py
+%fdupes %{buildroot}%{$python_sitelib}
+}
%check
%pytest shortuuid/tests.py
+%post
+%python_install_alternative shortuuid
+
+%postun
+%python_uninstall_alternative shortuuid
+
%files %{python_files}
-%doc README.rst
+%doc README.md
%license COPYING
-%{python_sitelib}/*
+%python_alternative %{_bindir}/shortuuid
+%{python_sitelib}/*shortuuid*/
%changelog
++++++ shortuuid-1.0.1.tar.gz -> shortuuid-1.0.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/COPYING new/shortuuid-1.0.8/COPYING
--- old/shortuuid-1.0.1/COPYING 2017-02-20 16:18:07.000000000 +0100
+++ new/shortuuid-1.0.8/COPYING 2021-11-11 12:19:06.507290400 +0100
@@ -1,20 +1,20 @@
-Copyright (c) 2011, Stochastic Technologies
+Copyright (c) 2011, Stavros Korokithakis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
-met:
+met:
Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
+this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
+documentation and/or other materials provided with the distribution.
Neither the name of Stochastic Technologies nor the names of its
contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
+this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -26,4 +26,4 @@
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/MANIFEST.in
new/shortuuid-1.0.8/MANIFEST.in
--- old/shortuuid-1.0.1/MANIFEST.in 2017-02-20 16:18:07.000000000 +0100
+++ new/shortuuid-1.0.8/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-include MANIFEST.in
-include COPYING
-include README.rst
-recursive-include shortuuid *.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/PKG-INFO new/shortuuid-1.0.8/PKG-INFO
--- old/shortuuid-1.0.1/PKG-INFO 2020-03-06 12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/PKG-INFO 2021-11-11 12:21:18.251320800 +0100
@@ -1,156 +1,223 @@
-Metadata-Version: 1.2
+Metadata-Version: 2.1
Name: shortuuid
-Version: 1.0.1
+Version: 1.0.8
Summary: A generator library for concise, unambiguous and URL-safe UUIDs.
-Home-page: https://github.com/stochastic-technologies/shortuuid/
-Author: Stochastic Technologies
-Author-email: [email protected]
+Home-page: https://github.com/skorokithakis/shortuuid/
License: BSD
-Description: ===========
- Description
- ===========
-
- ``shortuuid`` is a simple python library that generates concise,
unambiguous,
- URL-safe UUIDs.
-
- Often, one needs to use non-sequential IDs in places where users will
see them,
- but the IDs must be as concise and easy to use as possible.
``shortuuid`` solves
- this problem by generating uuids using Python's built-in ``uuid``
module and then
- translating them to base57 using lowercase and uppercase letters and
digits, and
- removing similar-looking characters such as l, 1, I, O and 0.
-
- .. image::
https://travis-ci.org/skorokithakis/shortuuid.svg?branch=master
- :target: https://travis-ci.org/skorokithakis/shortuuid
-
- Installation
- ------------
-
- To install ``shortuuid`` you need:
-
- * Python 2.5 or later in the 2.x line (earlier than 2.6 not tested),
or any 3.x.
-
- If you have the dependencies, you have multiple options of
installation:
-
- * With pip (preferred), do ``pip install shortuuid``.
- * With setuptools, do ``easy_install shortuuid``.
- * To install the source, download it from
- https://github.com/stochastic-technologies/shortuuid and do
- ``python setup.py install``.
-
- Usage
- -----
-
- To use ``shortuuid``, just import it in your project like so:
-
- >>> import shortuuid
-
- You can then generate a short UUID:
-
- >>> shortuuid.uuid()
- 'vytxeTZskVKR7C7WgdSP3d'
-
- If you prefer a version 5 UUID, you can pass a name (DNS or URL) to
the call and
- it will be used as a namespace (uuid.NAMESPACE_DNS or
uuid.NAMESPACE_URL) for the
- resulting UUID:
-
- >>> shortuuid.uuid(name="example.com")
- 'wpsWLdLt9nscn2jbTD3uxe'
- >>> shortuuid.uuid(name="http://example.com")
- 'c8sh5y9hdSMS6zVnrvf53T'
-
- You can also generate a cryptographically secure random string (using
- `os.urandom()`, internally) with:
-
- >>> shortuuid.ShortUUID().random(length=22)
- 'RaF56o2r58hTKT7AYS9doj'
-
-
- To see the alphabet that is being used to generate new UUIDs:
-
- >>> shortuuid.get_alphabet()
- '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
-
- If you want to use your own alphabet to generate UUIDs, use
``set_alphabet()``:
-
- >>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
- >>> shortuuid.uuid()
- '0agee20aa1hehebcagddhedddc0d2chhab3b'
-
- ``shortuuid`` will automatically sort and remove duplicates from your
alphabet to
- ensure consistency:
-
- >>> shortuuid.get_alphabet()
- '0123abcdefgh'
-
- If the default 22 digits are too long for you, you can get shorter IDs
by just
- truncating the string to the desired length. The IDs won't be
universally unique
- any longer, but the probability of a collision will still be very low.
-
- To serialize existing UUIDs, use ``encode()`` and ``decode()``:
-
- >>> import uuid ; u = uuid.uuid4() ; u
- UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
- >>> s = shortuuid.encode(u) ; s
- 'cu8Eo9RyrUsV4MXEiDZpLM'
- >>> shortuuid.decode(s) == u
- True
- >>> short = s[:7] ; short
- 'cu8Eo9R'
- >>> h = shortuuid.decode(short)
- UUID('00000000-0000-0000-0000-00b8c0b9f952')
- >>> shortuuid.decode(shortuuid.encode(h)) == h
- True
-
- Class-based usage
- -----------------
-
- If you need to have various alphabets per-thread, you can use the
`ShortUUID` class, like so:
-
- >>> su = shortuuid.ShortUUID(alphabet="01345678")
- >>> su.uuid()
- '034636353306816784480643806546503818874456'
- >>> su.get_alphabet()
- '01345678'
- >>> su.set_alphabet("21345687654123456")
- >>> su.get_alphabet()
- '12345678'
-
- Command-line usage
- ------------------
-
- `shortuuid` provides a simple way to generate a short UUID in a
terminal::
-
- $ python3 -m shortuuid
- fZpeF6gcskHbSpTgpQCkcJ
-
-
- (Replace `python3` with `py` if you are using Windows)
-
-
- Compatibility note
- ------------------
-
- Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB
last, i.e.
- reversed. This was later fixed, but if you have some UUIDs stored as a
string
- with the old method, you need to pass `legacy=True` to `decode()` when
- converting your strings back to UUIDs.
-
- That option will go away in the future, so you will want to convert
your UUIDs
- to strings using the new method. This can be done like so:
-
- >>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))
-
-
- License
- -------
-
- ``shortuuid`` is distributed under the BSD license.
-
-Platform: UNKNOWN
+Author: Stavros Korokithakis
+Author-email: [email protected]
+Requires-Python: >=3.5
Classifier: License :: OSI Approved :: BSD License
+Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
-Requires-Python: >=3.5
+Description-Content-Type: text/markdown
+
+Description
+===========
+
+`shortuuid` is a simple python library that generates concise, unambiguous,
URL-safe
+UUIDs.
+
+Often, one needs to use non-sequential IDs in places where users will see
them, but the
+IDs must be as concise and easy to use as possible. `shortuuid` solves this
problem by
+generating uuids using Python's built-in `uuid` module and then translating
them to
+base57 using lowercase and uppercase letters and digits, and removing
similar-looking
+characters such as l, 1, I, O and 0.
+
+[](https://travis-ci.org/skorokithakis/shortuuid)
+
+
+Installation
+------------
+
+To install `shortuuid` you need:
+
+- Python 3.x.
+
+If you have the dependencies, you have multiple options of installation:
+
+- With pip (preferred), do `pip install shortuuid`.
+- With setuptools, do `easy_install shortuuid`.
+- To install the source, download it from
+ https://github.com/stochastic-technologies/shortuuid and run `python
setup.py
+ install`.
+
+
+Usage
+-----
+
+To use `shortuuid`, just import it in your project like so:
+
+```python
+>>> import shortuuid
+```
+
+You can then generate a short UUID:
+
+```python
+>>> shortuuid.uuid()
+'vytxeTZskVKR7C7WgdSP3d'
+```
+
+If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call
and it will
+be used as a namespace (`uuid.NAMESPACE_DNS` or `uuid.NAMESPACE_URL`) for the
resulting
+UUID:
+
+```python
+>>> shortuuid.uuid(name="example.com")
+'wpsWLdLt9nscn2jbTD3uxe'
+
+>>> shortuuid.uuid(name="<http://example.com>")
+'c8sh5y9hdSMS6zVnrvf53T'
+```
+
+You can also generate a cryptographically secure random string (using
`os.urandom()`
+internally) with:
+
+```python
+>>> shortuuid.ShortUUID().random(length=22)
+'RaF56o2r58hTKT7AYS9doj'
+```
+
+To see the alphabet that is being used to generate new UUIDs:
+
+```python
+>>> shortuuid.get_alphabet()
+'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
+```
+
+If you want to use your own alphabet to generate UUIDs, use `set_alphabet()`:
+
+```python
+>>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
+>>> shortuuid.uuid()
+'0agee20aa1hehebcagddhedddc0d2chhab3b'
+```
+
+`shortuuid` will automatically sort and remove duplicates from your alphabet
to ensure
+consistency:
+
+```python
+>>> shortuuid.get_alphabet()
+'0123abcdefgh'
+```
+
+If the default 22 digits are too long for you, you can get shorter IDs by just
+truncating the string to the desired length. The IDs won't be universally
unique any
+longer, but the probability of a collision will still be very low.
+
+To serialize existing UUIDs, use `encode()` and `decode()`:
+
+```python
+>>> import uuid
+>>> u = uuid.uuid4()
+>>> u
+UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
+
+>>> s = shortuuid.encode(u)
+>>> s
+'cu8Eo9RyrUsV4MXEiDZpLM'
+
+>>> shortuuid.decode(s) == u
+True
+
+>>> short = s[:7]
+>>> short
+'cu8Eo9R'
+
+>>> h = shortuuid.decode(short)
+UUID('00000000-0000-0000-0000-00b8c0b9f952')
+
+>>> shortuuid.decode(shortuuid.encode(h)) == h
+True
+```
+
+
+Class-based usage
+-----------------
+
+If you need to have various alphabets per-thread, you can use the `ShortUUID`
class,
+like so:
+
+```python
+>>> su = shortuuid.ShortUUID(alphabet="01345678")
+>>> su.uuid()
+'034636353306816784480643806546503818874456'
+
+>>> su.get_alphabet()
+'01345678'
+
+>>> su.set_alphabet("21345687654123456")
+>>> su.get_alphabet()
+'12345678'
+```
+
+
+Command-line usage
+------------------
+
+`shortuuid` provides a simple way to generate a short UUID in a terminal:
+
+```bash
+$ python3 -m shortuuid
+fZpeF6gcskHbSpTgpQCkcJ
+```
+
+(Replace `python3` with `py` if you are using Windows).
+
+
+Django field
+------------
+
+`shortuuid` includes a Django field that generates random short UUIDs by
default, for
+your convenience:
+
+```python
+from shortuuid.django_fields import ShortUUIDField
+
+class MyModel(models.Model):
+ # A primary key ID of length 16 and a short alphabet.
+ id = ShortUUIDField(
+ length=16,
+ max_length=40,
+ prefix="id_",
+ alphabet="abcdefg1234",
+ primary_key=True,
+ )
+
+ # A short UUID of length 22 and the default alphabet.
+ api_key = ShortUUIDField()
+```
+
+The field is the same as the `CharField`, with a `length` argument (the length
of the
+ID), an `alphabet` argument, and the `default` argument removed. Everything
else is
+exactly the same, e.g. `index`, `help_text`, `max_length`, etc.
+
+
+Compatibility note
+------------------
+
+Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB last, i.e.
reversed.
+This was later fixed, but if you have some UUIDs stored as a string with the
old method,
+you need to pass `legacy=True` to `decode()` when converting your strings back
to UUIDs.
+
+That option will go away in the future, so you will want to convert your UUIDs
to
+strings using the new method. This can be done like so:
+
+```python
+>>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))
+```
+
+License
+-------
+
+`shortuuid` is distributed under the BSD license.
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/README.md
new/shortuuid-1.0.8/README.md
--- old/shortuuid-1.0.1/README.md 1970-01-01 01:00:00.000000000 +0100
+++ new/shortuuid-1.0.8/README.md 2021-11-08 22:59:09.717791000 +0100
@@ -0,0 +1,200 @@
+Description
+===========
+
+`shortuuid` is a simple python library that generates concise, unambiguous,
URL-safe
+UUIDs.
+
+Often, one needs to use non-sequential IDs in places where users will see
them, but the
+IDs must be as concise and easy to use as possible. `shortuuid` solves this
problem by
+generating uuids using Python's built-in `uuid` module and then translating
them to
+base57 using lowercase and uppercase letters and digits, and removing
similar-looking
+characters such as l, 1, I, O and 0.
+
+[](https://travis-ci.org/skorokithakis/shortuuid)
+
+
+Installation
+------------
+
+To install `shortuuid` you need:
+
+- Python 3.x.
+
+If you have the dependencies, you have multiple options of installation:
+
+- With pip (preferred), do `pip install shortuuid`.
+- With setuptools, do `easy_install shortuuid`.
+- To install the source, download it from
+ https://github.com/stochastic-technologies/shortuuid and run `python
setup.py
+ install`.
+
+
+Usage
+-----
+
+To use `shortuuid`, just import it in your project like so:
+
+```python
+>>> import shortuuid
+```
+
+You can then generate a short UUID:
+
+```python
+>>> shortuuid.uuid()
+'vytxeTZskVKR7C7WgdSP3d'
+```
+
+If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call
and it will
+be used as a namespace (`uuid.NAMESPACE_DNS` or `uuid.NAMESPACE_URL`) for the
resulting
+UUID:
+
+```python
+>>> shortuuid.uuid(name="example.com")
+'wpsWLdLt9nscn2jbTD3uxe'
+
+>>> shortuuid.uuid(name="<http://example.com>")
+'c8sh5y9hdSMS6zVnrvf53T'
+```
+
+You can also generate a cryptographically secure random string (using
`os.urandom()`
+internally) with:
+
+```python
+>>> shortuuid.ShortUUID().random(length=22)
+'RaF56o2r58hTKT7AYS9doj'
+```
+
+To see the alphabet that is being used to generate new UUIDs:
+
+```python
+>>> shortuuid.get_alphabet()
+'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
+```
+
+If you want to use your own alphabet to generate UUIDs, use `set_alphabet()`:
+
+```python
+>>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
+>>> shortuuid.uuid()
+'0agee20aa1hehebcagddhedddc0d2chhab3b'
+```
+
+`shortuuid` will automatically sort and remove duplicates from your alphabet
to ensure
+consistency:
+
+```python
+>>> shortuuid.get_alphabet()
+'0123abcdefgh'
+```
+
+If the default 22 digits are too long for you, you can get shorter IDs by just
+truncating the string to the desired length. The IDs won't be universally
unique any
+longer, but the probability of a collision will still be very low.
+
+To serialize existing UUIDs, use `encode()` and `decode()`:
+
+```python
+>>> import uuid
+>>> u = uuid.uuid4()
+>>> u
+UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
+
+>>> s = shortuuid.encode(u)
+>>> s
+'cu8Eo9RyrUsV4MXEiDZpLM'
+
+>>> shortuuid.decode(s) == u
+True
+
+>>> short = s[:7]
+>>> short
+'cu8Eo9R'
+
+>>> h = shortuuid.decode(short)
+UUID('00000000-0000-0000-0000-00b8c0b9f952')
+
+>>> shortuuid.decode(shortuuid.encode(h)) == h
+True
+```
+
+
+Class-based usage
+-----------------
+
+If you need to have various alphabets per-thread, you can use the `ShortUUID`
class,
+like so:
+
+```python
+>>> su = shortuuid.ShortUUID(alphabet="01345678")
+>>> su.uuid()
+'034636353306816784480643806546503818874456'
+
+>>> su.get_alphabet()
+'01345678'
+
+>>> su.set_alphabet("21345687654123456")
+>>> su.get_alphabet()
+'12345678'
+```
+
+
+Command-line usage
+------------------
+
+`shortuuid` provides a simple way to generate a short UUID in a terminal:
+
+```bash
+$ python3 -m shortuuid
+fZpeF6gcskHbSpTgpQCkcJ
+```
+
+(Replace `python3` with `py` if you are using Windows).
+
+
+Django field
+------------
+
+`shortuuid` includes a Django field that generates random short UUIDs by
default, for
+your convenience:
+
+```python
+from shortuuid.django_fields import ShortUUIDField
+
+class MyModel(models.Model):
+ # A primary key ID of length 16 and a short alphabet.
+ id = ShortUUIDField(
+ length=16,
+ max_length=40,
+ prefix="id_",
+ alphabet="abcdefg1234",
+ primary_key=True,
+ )
+
+ # A short UUID of length 22 and the default alphabet.
+ api_key = ShortUUIDField()
+```
+
+The field is the same as the `CharField`, with a `length` argument (the length
of the
+ID), an `alphabet` argument, and the `default` argument removed. Everything
else is
+exactly the same, e.g. `index`, `help_text`, `max_length`, etc.
+
+
+Compatibility note
+------------------
+
+Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB last, i.e.
reversed.
+This was later fixed, but if you have some UUIDs stored as a string with the
old method,
+you need to pass `legacy=True` to `decode()` when converting your strings back
to UUIDs.
+
+That option will go away in the future, so you will want to convert your UUIDs
to
+strings using the new method. This can be done like so:
+
+```python
+>>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))
+```
+
+License
+-------
+
+`shortuuid` is distributed under the BSD license.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/README.rst
new/shortuuid-1.0.8/README.rst
--- old/shortuuid-1.0.1/README.rst 2020-03-06 12:05:05.000000000 +0100
+++ new/shortuuid-1.0.8/README.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,139 +0,0 @@
-===========
-Description
-===========
-
-``shortuuid`` is a simple python library that generates concise, unambiguous,
-URL-safe UUIDs.
-
-Often, one needs to use non-sequential IDs in places where users will see them,
-but the IDs must be as concise and easy to use as possible. ``shortuuid``
solves
-this problem by generating uuids using Python's built-in ``uuid`` module and
then
-translating them to base57 using lowercase and uppercase letters and digits,
and
-removing similar-looking characters such as l, 1, I, O and 0.
-
-.. image:: https://travis-ci.org/skorokithakis/shortuuid.svg?branch=master
- :target: https://travis-ci.org/skorokithakis/shortuuid
-
-Installation
-------------
-
-To install ``shortuuid`` you need:
-
-* Python 2.5 or later in the 2.x line (earlier than 2.6 not tested), or any
3.x.
-
-If you have the dependencies, you have multiple options of installation:
-
-* With pip (preferred), do ``pip install shortuuid``.
-* With setuptools, do ``easy_install shortuuid``.
-* To install the source, download it from
- https://github.com/stochastic-technologies/shortuuid and do
- ``python setup.py install``.
-
-Usage
------
-
-To use ``shortuuid``, just import it in your project like so:
-
->>> import shortuuid
-
-You can then generate a short UUID:
-
->>> shortuuid.uuid()
-'vytxeTZskVKR7C7WgdSP3d'
-
-If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call
and
-it will be used as a namespace (uuid.NAMESPACE_DNS or uuid.NAMESPACE_URL) for
the
-resulting UUID:
-
->>> shortuuid.uuid(name="example.com")
-'wpsWLdLt9nscn2jbTD3uxe'
->>> shortuuid.uuid(name="http://example.com")
-'c8sh5y9hdSMS6zVnrvf53T'
-
-You can also generate a cryptographically secure random string (using
-`os.urandom()`, internally) with:
-
->>> shortuuid.ShortUUID().random(length=22)
-'RaF56o2r58hTKT7AYS9doj'
-
-
-To see the alphabet that is being used to generate new UUIDs:
-
->>> shortuuid.get_alphabet()
-'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
-
-If you want to use your own alphabet to generate UUIDs, use ``set_alphabet()``:
-
->>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
->>> shortuuid.uuid()
-'0agee20aa1hehebcagddhedddc0d2chhab3b'
-
-``shortuuid`` will automatically sort and remove duplicates from your alphabet
to
-ensure consistency:
-
->>> shortuuid.get_alphabet()
-'0123abcdefgh'
-
-If the default 22 digits are too long for you, you can get shorter IDs by just
-truncating the string to the desired length. The IDs won't be universally
unique
-any longer, but the probability of a collision will still be very low.
-
-To serialize existing UUIDs, use ``encode()`` and ``decode()``:
-
->>> import uuid ; u = uuid.uuid4() ; u
-UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
->>> s = shortuuid.encode(u) ; s
-'cu8Eo9RyrUsV4MXEiDZpLM'
->>> shortuuid.decode(s) == u
-True
->>> short = s[:7] ; short
-'cu8Eo9R'
->>> h = shortuuid.decode(short)
-UUID('00000000-0000-0000-0000-00b8c0b9f952')
->>> shortuuid.decode(shortuuid.encode(h)) == h
-True
-
-Class-based usage
------------------
-
-If you need to have various alphabets per-thread, you can use the `ShortUUID`
class, like so:
-
->>> su = shortuuid.ShortUUID(alphabet="01345678")
->>> su.uuid()
-'034636353306816784480643806546503818874456'
->>> su.get_alphabet()
-'01345678'
->>> su.set_alphabet("21345687654123456")
->>> su.get_alphabet()
-'12345678'
-
-Command-line usage
-------------------
-
-`shortuuid` provides a simple way to generate a short UUID in a terminal::
-
- $ python3 -m shortuuid
- fZpeF6gcskHbSpTgpQCkcJ
-
-
-(Replace `python3` with `py` if you are using Windows)
-
-
-Compatibility note
-------------------
-
-Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB last, i.e.
-reversed. This was later fixed, but if you have some UUIDs stored as a string
-with the old method, you need to pass `legacy=True` to `decode()` when
-converting your strings back to UUIDs.
-
-That option will go away in the future, so you will want to convert your UUIDs
-to strings using the new method. This can be done like so:
-
->>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))
-
-
-License
--------
-
-``shortuuid`` is distributed under the BSD license.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/pyproject.toml
new/shortuuid-1.0.8/pyproject.toml
--- old/shortuuid-1.0.1/pyproject.toml 1970-01-01 01:00:00.000000000 +0100
+++ new/shortuuid-1.0.8/pyproject.toml 2021-11-11 12:20:53.295497200 +0100
@@ -0,0 +1,26 @@
+[tool.poetry]
+name = "shortuuid"
+version = "1.0.8"
+description = "A generator library for concise, unambiguous and URL-safe
UUIDs."
+license = "BSD"
+classifiers = [
+ "License :: OSI Approved :: BSD License",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Topic :: Software Development :: Libraries :: Python Modules"
+]
+homepage = "https://github.com/skorokithakis/shortuuid/"
+authors = ["Stavros Korokithakis <[email protected]>"]
+readme = "README.md"
+include = ["COPYING"]
+
+[tool.poetry.scripts]
+shortuuid = "shortuuid:cli.main"
+
+[tool.poetry.dependencies]
+python = ">=3.5"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/setup.cfg
new/shortuuid-1.0.8/setup.cfg
--- old/shortuuid-1.0.1/setup.cfg 2020-03-06 12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/setup.cfg 1970-01-01 01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
-[flake8]
-exclude =
-ignore = F403,E128,E126,E123,E121,E203,E265,E501,W503
-import-order-style = smarkets
-
-[isort]
-include_trailing_comma = true
-line_length = 120
-force_grid_wrap = 0
-multi_line_output = 3
-
-[pep8]
-max-line-length = 120
-
-[egg_info]
-tag_build =
-tag_date = 0
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/setup.py new/shortuuid-1.0.8/setup.py
--- old/shortuuid-1.0.1/setup.py 2020-03-06 12:48:29.000000000 +0100
+++ new/shortuuid-1.0.8/setup.py 2021-11-11 12:21:18.251116500 +0100
@@ -1,33 +1,30 @@
-#!/usr/bin/env python
-import sys
-
+# -*- coding: utf-8 -*-
from setuptools import setup
-from shortuuid import __version__
+packages = \
+['shortuuid']
+
+package_data = \
+{'': ['*']}
+
+entry_points = \
+{'console_scripts': ['shortuuid = shortuuid:cli.main']}
+
+setup_kwargs = {
+ 'name': 'shortuuid',
+ 'version': '1.0.8',
+ 'description': 'A generator library for concise, unambiguous and URL-safe
UUIDs.',
+ 'long_description': 'Description\n===========\n\n`shortuuid` is a simple
python library that generates concise, unambiguous, URL-safe\nUUIDs.\n\nOften,
one needs to use non-sequential IDs in places where users will see them, but
the\nIDs must be as concise and easy to use as possible. `shortuuid` solves
this problem by\ngenerating uuids using Python\'s built-in `uuid` module and
then translating them to\nbase57 using lowercase and uppercase letters and
digits, and removing similar-looking\ncharacters such as l, 1, I, O and
0.\n\n[](https://travis-ci.org/skorokithakis/shortuuid)\n\n\nInstallation\n------------\n\nTo
install `shortuuid` you need:\n\n- Python 3.x.\n\nIf you have the
dependencies, you have multiple options of installation:\n\n- With pip
(preferred), do `pip install shortuuid`.\n- With setuptools, do `easy_install
shortuuid`.\n- To install the source, download it from\n https://githu
b.com/stochastic-technologies/shortuuid and run `python setup.py\n
install`.\n\n\nUsage\n-----\n\nTo use `shortuuid`, just import it in your
project like so:\n\n```python\n>>> import shortuuid\n```\n\nYou can then
generate a short UUID:\n\n```python\n>>>
shortuuid.uuid()\n\'vytxeTZskVKR7C7WgdSP3d\'\n```\n\nIf you prefer a version 5
UUID, you can pass a name (DNS or URL) to the call and it will\nbe used as a
namespace (`uuid.NAMESPACE_DNS` or `uuid.NAMESPACE_URL`) for the
resulting\nUUID:\n\n```python\n>>>
shortuuid.uuid(name="example.com")\n\'wpsWLdLt9nscn2jbTD3uxe\'\n\n>>>
shortuuid.uuid(name="<http://example.com>")\n\'c8sh5y9hdSMS6zVnrvf53T\'\n```\n\nYou
can also generate a cryptographically secure random string (using
`os.urandom()`\ninternally) with:\n\n```python\n>>>
shortuuid.ShortUUID().random(length=22)\n\'RaF56o2r58hTKT7AYS9doj\'\n```\n\nTo
see the alphabet that is being used to generate new UUIDs:\n\n```python\n>>>
shortuuid.get_alphabet()\n\'23456789ABCDEFGHJKLMNPQRSTU
VWXYZabcdefghijkmnopqrstuvwxyz\'\n```\n\nIf you want to use your own alphabet
to generate UUIDs, use `set_alphabet()`:\n\n```python\n>>>
shortuuid.set_alphabet("aaaaabcdefgh1230123")\n>>>
shortuuid.uuid()\n\'0agee20aa1hehebcagddhedddc0d2chhab3b\'\n```\n\n`shortuuid`
will automatically sort and remove duplicates from your alphabet to
ensure\nconsistency:\n\n```python\n>>>
shortuuid.get_alphabet()\n\'0123abcdefgh\'\n```\n\nIf the default 22 digits are
too long for you, you can get shorter IDs by just\ntruncating the string to the
desired length. The IDs won\'t be universally unique any\nlonger, but the
probability of a collision will still be very low.\n\nTo serialize existing
UUIDs, use `encode()` and `decode()`:\n\n```python\n>>> import uuid\n>>> u =
uuid.uuid4()\n>>> u\nUUID(\'6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a\')\n\n>>> s =
shortuuid.encode(u)\n>>> s\n\'cu8Eo9RyrUsV4MXEiDZpLM\'\n\n>>>
shortuuid.decode(s) == u\nTrue\n\n>>> short = s[:7]\n>>>
short\n\'cu8Eo9R\'\n\n>>> h = shortuui
d.decode(short)\nUUID(\'00000000-0000-0000-0000-00b8c0b9f952\')\n\n>>>
shortuuid.decode(shortuuid.encode(h)) == h\nTrue\n```\n\n\nClass-based
usage\n-----------------\n\nIf you need to have various alphabets per-thread,
you can use the `ShortUUID` class,\nlike so:\n\n```python\n>>> su =
shortuuid.ShortUUID(alphabet="01345678")\n>>>
su.uuid()\n\'034636353306816784480643806546503818874456\'\n\n>>>
su.get_alphabet()\n\'01345678\'\n\n>>>
su.set_alphabet("21345687654123456")\n>>>
su.get_alphabet()\n\'12345678\'\n```\n\n\nCommand-line
usage\n------------------\n\n`shortuuid` provides a simple way to generate a
short UUID in a terminal:\n\n```bash\n$ python3 -m
shortuuid\nfZpeF6gcskHbSpTgpQCkcJ\n```\n\n(Replace `python3` with `py` if you
are using Windows).\n\n\nDjango field\n------------\n\n`shortuuid` includes a
Django field that generates random short UUIDs by default, for\nyour
convenience:\n\n```python\nfrom shortuuid.django_fields import
ShortUUIDField\n\nclass MyModel(models.Model):
\n # A primary key ID of length 16 and a short alphabet.\n id =
ShortUUIDField(\n length=16,\n max_length=40,\n
prefix="id_",\n alphabet="abcdefg1234",\n primary_key=True,\n
)\n\n # A short UUID of length 22 and the default alphabet.\n api_key =
ShortUUIDField()\n```\n\nThe field is the same as the `CharField`, with a
`length` argument (the length of the\nID), an `alphabet` argument, and the
`default` argument removed. Everything else is\nexactly the same, e.g. `index`,
`help_text`, `max_length`, etc.\n\n\nCompatibility
note\n------------------\n\nVersions of ShortUUID prior to 1.0.0 generated
UUIDs with their MSB last, i.e. reversed.\nThis was later fixed, but if you
have some UUIDs stored as a string with the old method,\nyou need to pass
`legacy=True` to `decode()` when converting your strings back to UUIDs.\n\nThat
option will go away in the future, so you will want to convert your UUIDs
to\nstrings using the new method. This can
be done like so:\n\n```python\n>>> new_uuid_str = encode(decode(old_uuid_str,
legacy=True))\n```\n\nLicense\n-------\n\n`shortuuid` is distributed under the
BSD license.\n',
+ 'author': 'Stavros Korokithakis',
+ 'author_email': '[email protected]',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'url': 'https://github.com/skorokithakis/shortuuid/',
+ 'packages': packages,
+ 'package_data': package_data,
+ 'entry_points': entry_points,
+ 'python_requires': '>=3.5',
+}
-assert sys.version >= "3.5", "Requires Python v3.5 or above."
-classifiers = [
- "License :: OSI Approved :: BSD License",
- "Programming Language :: Python",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7",
- "Topic :: Software Development :: Libraries :: Python Modules",
-]
-
-setup(
- name="shortuuid",
- version=__version__,
- author="Stochastic Technologies",
- author_email="[email protected]",
- url="https://github.com/stochastic-technologies/shortuuid/",
- long_description=open("README.rst").read(),
- description="A generator library for concise, " "unambiguous and URL-safe
UUIDs.",
- license="BSD",
- python_requires=">=3.5",
- classifiers=classifiers,
- packages=["shortuuid"],
- test_suite="shortuuid.tests",
- tests_require=[],
-)
+setup(**setup_kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/__init__.py
new/shortuuid-1.0.8/shortuuid/__init__.py
--- old/shortuuid-1.0.1/shortuuid/__init__.py 2020-03-06 12:45:51.000000000
+0100
+++ new/shortuuid-1.0.8/shortuuid/__init__.py 2021-11-11 12:20:57.556465900
+0100
@@ -1,10 +1,9 @@
-# flake8: noqa
-from shortuuid.main import decode
-from shortuuid.main import encode
-from shortuuid.main import get_alphabet
-from shortuuid.main import random
-from shortuuid.main import set_alphabet
-from shortuuid.main import ShortUUID
-from shortuuid.main import uuid
+from shortuuid.main import decode # noqa
+from shortuuid.main import encode # noqa
+from shortuuid.main import get_alphabet # noqa
+from shortuuid.main import random # noqa
+from shortuuid.main import set_alphabet # noqa
+from shortuuid.main import ShortUUID # noqa
+from shortuuid.main import uuid # noqa
-__version__ = "1.0.1"
+__version__ = "1.0.8"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/__main__.py
new/shortuuid-1.0.8/shortuuid/__main__.py
--- old/shortuuid-1.0.1/shortuuid/__main__.py 2020-03-05 14:06:09.000000000
+0100
+++ new/shortuuid-1.0.8/shortuuid/__main__.py 1970-01-01 01:00:00.000000000
+0100
@@ -1,4 +0,0 @@
-from .main import uuid
-
-if __name__ == "__main__":
- print(uuid())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/cli.py
new/shortuuid-1.0.8/shortuuid/cli.py
--- old/shortuuid-1.0.1/shortuuid/cli.py 1970-01-01 01:00:00.000000000
+0100
+++ new/shortuuid-1.0.8/shortuuid/cli.py 2021-11-08 17:04:26.319352000
+0100
@@ -0,0 +1,5 @@
+from .main import uuid
+
+
+def main():
+ print(uuid())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/django_fields.py
new/shortuuid-1.0.8/shortuuid/django_fields.py
--- old/shortuuid-1.0.1/shortuuid/django_fields.py 1970-01-01
01:00:00.000000000 +0100
+++ new/shortuuid-1.0.8/shortuuid/django_fields.py 2021-11-08
22:54:03.408503800 +0100
@@ -0,0 +1,35 @@
+from django.db import models
+from django.utils.translation import gettext_lazy as _
+
+from . import ShortUUID
+
+
+class ShortUUIDField(models.CharField):
+ description = _("A short UUID field.")
+
+ def __init__(self, *args, **kwargs):
+ self.length = kwargs.pop("length", 22)
+ self.prefix = kwargs.pop("prefix", "")
+
+ if "max_length" not in kwargs:
+ # If `max_length` was not specified, set it here.
+ kwargs["max_length"] = self.length
+
+ self.alphabet = kwargs.pop("alphabet", None)
+ kwargs["default"] = self._generate_uuid
+
+ super().__init__(*args, **kwargs)
+
+ def _generate_uuid(self):
+ """Generate a short random string."""
+ return self.prefix + ShortUUID(alphabet=self.alphabet).random(
+ length=self.length
+ )
+
+ def deconstruct(self):
+ name, path, args, kwargs = super().deconstruct()
+ kwargs["alphabet"] = self.alphabet
+ kwargs["length"] = self.length
+ kwargs["prefix"] = self.prefix
+ kwargs.pop("default", None)
+ return name, path, args, kwargs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/main.py
new/shortuuid-1.0.8/shortuuid/main.py
--- old/shortuuid-1.0.1/shortuuid/main.py 2020-03-06 12:11:07.000000000
+0100
+++ new/shortuuid-1.0.8/shortuuid/main.py 2021-11-08 03:12:51.636893000
+0100
@@ -1,4 +1,4 @@
-""" Concise UUID generation. """
+"""Concise UUID generation."""
import binascii
import math
import os
@@ -8,6 +8,7 @@
def int_to_string(number, alphabet, padding=None):
"""
Convert a number to a string, using the given alphabet.
+
The output has the most significant digit first.
"""
output = ""
@@ -24,6 +25,7 @@
def string_to_int(string, alphabet):
"""
Convert a string to a number, using the given alphabet.
+
The input is assumed to have the most significant digit first.
"""
number = 0
@@ -36,39 +38,42 @@
class ShortUUID(object):
def __init__(self, alphabet=None):
if alphabet is None:
- alphabet = list("23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
"abcdefghijkmnopqrstuvwxyz")
+ alphabet = list(
+ "23456789ABCDEFGHJKLMNPQRSTUVWXYZ" "abcdefghijkmnopqrstuvwxyz"
+ )
self.set_alphabet(alphabet)
@property
def _length(self):
- """
- Return the necessary length to fit the entire UUID given
- the current alphabet.
- """
+ """Return the necessary length to fit the entire UUID given the
current alphabet."""
return int(math.ceil(math.log(2 ** 128, self._alpha_len)))
def encode(self, uuid, pad_length=None):
"""
- Encode a UUID into a string (LSB first) according to the alphabet
+ Encode a UUID into a string (LSB first) according to the alphabet.
If leftmost (MSB) bits are 0, the string might be shorter.
"""
+ if not isinstance(uuid, _uu.UUID):
+ raise ValueError("Input `uuid` must be a UUID object.")
if pad_length is None:
pad_length = self._length
return int_to_string(uuid.int, self._alphabet, padding=pad_length)
def decode(self, string, legacy=False):
"""
- Decode a string according to the current alphabet into a UUID
- Raises ValueError when encountering illegal characters
- or a too-long string.
+ Decode a string according to the current alphabet into a UUID.
+
+ Raises ValueError when encountering illegal characters or a too-long
string.
If string too short, fills leftmost (MSB) bits with 0.
- Pass `legacy=True` if your UUID was encoded with a ShortUUID version
- prior to 1.0.0.
+ Pass `legacy=True` if your UUID was encoded with a ShortUUID version
prior to
+ 1.0.0.
"""
+ if not isinstance(string, str):
+ raise ValueError("Input `string` must be a str.")
if legacy:
string = string[::-1]
return _uu.UUID(int=string_to_int(string, self._alphabet))
@@ -93,10 +98,7 @@
return self.encode(u, pad_length)
def random(self, length=None):
- """
- Generate and return a cryptographically-secure short random string
- of the specified length.
- """
+ """Generate and return a cryptographically secure short random string
of `length`."""
if length is None:
length = self._length
@@ -109,7 +111,6 @@
def set_alphabet(self, alphabet):
"""Set the alphabet to be used for new UUIDs."""
-
# Turn the alphabet into a set and sort it to prevent duplicates
# and ensure reproducibility.
new_alphabet = list(sorted(set(alphabet)))
@@ -120,9 +121,7 @@
raise ValueError("Alphabet with more than " "one unique symbols
required.")
def encoded_length(self, num_bytes=16):
- """
- Returns the string length of the shortened UUID.
- """
+ """Return the string length of the shortened UUID."""
factor = math.log(256) / math.log(self._alpha_len)
return int(math.ceil(factor * num_bytes))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid/tests.py
new/shortuuid-1.0.8/shortuuid/tests.py
--- old/shortuuid-1.0.1/shortuuid/tests.py 2020-03-06 12:11:07.000000000
+0100
+++ new/shortuuid-1.0.8/shortuuid/tests.py 2021-11-08 03:09:54.956199400
+0100
@@ -117,7 +117,9 @@
su1 = ShortUUID()
self.assertEqual(su1.encoded_length(), 22)
- base64_alphabet = string.ascii_uppercase + string.ascii_lowercase +
string.digits + "+/"
+ base64_alphabet = (
+ string.ascii_uppercase + string.ascii_lowercase + string.digits +
"+/"
+ )
su2 = ShortUUID(base64_alphabet)
self.assertEqual(su2.encoded_length(), 22)
@@ -171,5 +173,25 @@
self.assertEqual(uid_lengths[uid_length], num_iterations)
+class EncodingEdgeCasesTest(unittest.TestCase):
+ def test_decode_dict(self):
+ su = ShortUUID()
+ self.assertRaises(ValueError, su.encode, [])
+ self.assertRaises(ValueError, su.encode, {})
+ self.assertRaises(ValueError, su.decode, (2,))
+ self.assertRaises(ValueError, su.encode, 42)
+ self.assertRaises(ValueError, su.encode, 42.0)
+
+
+class DecodingEdgeCasesTest(unittest.TestCase):
+ def test_decode_dict(self):
+ su = ShortUUID()
+ self.assertRaises(ValueError, su.decode, [])
+ self.assertRaises(ValueError, su.decode, {})
+ self.assertRaises(ValueError, su.decode, (2,))
+ self.assertRaises(ValueError, su.decode, 42)
+ self.assertRaises(ValueError, su.decode, 42.0)
+
+
if __name__ == "__main__":
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid.egg-info/PKG-INFO
new/shortuuid-1.0.8/shortuuid.egg-info/PKG-INFO
--- old/shortuuid-1.0.1/shortuuid.egg-info/PKG-INFO 2020-03-06
12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/shortuuid.egg-info/PKG-INFO 1970-01-01
01:00:00.000000000 +0100
@@ -1,156 +0,0 @@
-Metadata-Version: 1.2
-Name: shortuuid
-Version: 1.0.1
-Summary: A generator library for concise, unambiguous and URL-safe UUIDs.
-Home-page: https://github.com/stochastic-technologies/shortuuid/
-Author: Stochastic Technologies
-Author-email: [email protected]
-License: BSD
-Description: ===========
- Description
- ===========
-
- ``shortuuid`` is a simple python library that generates concise,
unambiguous,
- URL-safe UUIDs.
-
- Often, one needs to use non-sequential IDs in places where users will
see them,
- but the IDs must be as concise and easy to use as possible.
``shortuuid`` solves
- this problem by generating uuids using Python's built-in ``uuid``
module and then
- translating them to base57 using lowercase and uppercase letters and
digits, and
- removing similar-looking characters such as l, 1, I, O and 0.
-
- .. image::
https://travis-ci.org/skorokithakis/shortuuid.svg?branch=master
- :target: https://travis-ci.org/skorokithakis/shortuuid
-
- Installation
- ------------
-
- To install ``shortuuid`` you need:
-
- * Python 2.5 or later in the 2.x line (earlier than 2.6 not tested),
or any 3.x.
-
- If you have the dependencies, you have multiple options of
installation:
-
- * With pip (preferred), do ``pip install shortuuid``.
- * With setuptools, do ``easy_install shortuuid``.
- * To install the source, download it from
- https://github.com/stochastic-technologies/shortuuid and do
- ``python setup.py install``.
-
- Usage
- -----
-
- To use ``shortuuid``, just import it in your project like so:
-
- >>> import shortuuid
-
- You can then generate a short UUID:
-
- >>> shortuuid.uuid()
- 'vytxeTZskVKR7C7WgdSP3d'
-
- If you prefer a version 5 UUID, you can pass a name (DNS or URL) to
the call and
- it will be used as a namespace (uuid.NAMESPACE_DNS or
uuid.NAMESPACE_URL) for the
- resulting UUID:
-
- >>> shortuuid.uuid(name="example.com")
- 'wpsWLdLt9nscn2jbTD3uxe'
- >>> shortuuid.uuid(name="http://example.com")
- 'c8sh5y9hdSMS6zVnrvf53T'
-
- You can also generate a cryptographically secure random string (using
- `os.urandom()`, internally) with:
-
- >>> shortuuid.ShortUUID().random(length=22)
- 'RaF56o2r58hTKT7AYS9doj'
-
-
- To see the alphabet that is being used to generate new UUIDs:
-
- >>> shortuuid.get_alphabet()
- '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
-
- If you want to use your own alphabet to generate UUIDs, use
``set_alphabet()``:
-
- >>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
- >>> shortuuid.uuid()
- '0agee20aa1hehebcagddhedddc0d2chhab3b'
-
- ``shortuuid`` will automatically sort and remove duplicates from your
alphabet to
- ensure consistency:
-
- >>> shortuuid.get_alphabet()
- '0123abcdefgh'
-
- If the default 22 digits are too long for you, you can get shorter IDs
by just
- truncating the string to the desired length. The IDs won't be
universally unique
- any longer, but the probability of a collision will still be very low.
-
- To serialize existing UUIDs, use ``encode()`` and ``decode()``:
-
- >>> import uuid ; u = uuid.uuid4() ; u
- UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
- >>> s = shortuuid.encode(u) ; s
- 'cu8Eo9RyrUsV4MXEiDZpLM'
- >>> shortuuid.decode(s) == u
- True
- >>> short = s[:7] ; short
- 'cu8Eo9R'
- >>> h = shortuuid.decode(short)
- UUID('00000000-0000-0000-0000-00b8c0b9f952')
- >>> shortuuid.decode(shortuuid.encode(h)) == h
- True
-
- Class-based usage
- -----------------
-
- If you need to have various alphabets per-thread, you can use the
`ShortUUID` class, like so:
-
- >>> su = shortuuid.ShortUUID(alphabet="01345678")
- >>> su.uuid()
- '034636353306816784480643806546503818874456'
- >>> su.get_alphabet()
- '01345678'
- >>> su.set_alphabet("21345687654123456")
- >>> su.get_alphabet()
- '12345678'
-
- Command-line usage
- ------------------
-
- `shortuuid` provides a simple way to generate a short UUID in a
terminal::
-
- $ python3 -m shortuuid
- fZpeF6gcskHbSpTgpQCkcJ
-
-
- (Replace `python3` with `py` if you are using Windows)
-
-
- Compatibility note
- ------------------
-
- Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB
last, i.e.
- reversed. This was later fixed, but if you have some UUIDs stored as a
string
- with the old method, you need to pass `legacy=True` to `decode()` when
- converting your strings back to UUIDs.
-
- That option will go away in the future, so you will want to convert
your UUIDs
- to strings using the new method. This can be done like so:
-
- >>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))
-
-
- License
- -------
-
- ``shortuuid`` is distributed under the BSD license.
-
-Platform: UNKNOWN
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
-Classifier: Programming Language :: Python :: 3.7
-Classifier: Topic :: Software Development :: Libraries :: Python Modules
-Requires-Python: >=3.5
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid.egg-info/SOURCES.txt
new/shortuuid-1.0.8/shortuuid.egg-info/SOURCES.txt
--- old/shortuuid-1.0.1/shortuuid.egg-info/SOURCES.txt 2020-03-06
12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/shortuuid.egg-info/SOURCES.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1,13 +0,0 @@
-COPYING
-MANIFEST.in
-README.rst
-setup.cfg
-setup.py
-shortuuid/__init__.py
-shortuuid/__main__.py
-shortuuid/main.py
-shortuuid/tests.py
-shortuuid.egg-info/PKG-INFO
-shortuuid.egg-info/SOURCES.txt
-shortuuid.egg-info/dependency_links.txt
-shortuuid.egg-info/top_level.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/shortuuid-1.0.1/shortuuid.egg-info/dependency_links.txt
new/shortuuid-1.0.8/shortuuid.egg-info/dependency_links.txt
--- old/shortuuid-1.0.1/shortuuid.egg-info/dependency_links.txt 2020-03-06
12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/shortuuid.egg-info/dependency_links.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-1.0.1/shortuuid.egg-info/top_level.txt
new/shortuuid-1.0.8/shortuuid.egg-info/top_level.txt
--- old/shortuuid-1.0.1/shortuuid.egg-info/top_level.txt 2020-03-06
12:49:32.000000000 +0100
+++ new/shortuuid-1.0.8/shortuuid.egg-info/top_level.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1 +0,0 @@
-shortuuid