Hello community,
here is the log from the commit of package python-shortuuid for
openSUSE:Factory checked in at 2020-03-19 19:49:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-shortuuid (Old)
and /work/SRC/openSUSE:Factory/.python-shortuuid.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-shortuuid"
Thu Mar 19 19:49:50 2020 rev:3 rq:786236 version:1.0.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-shortuuid/python-shortuuid.changes
2018-09-28 08:52:58.381766196 +0200
+++
/work/SRC/openSUSE:Factory/.python-shortuuid.new.3160/python-shortuuid.changes
2020-03-19 19:53:48.220276632 +0100
@@ -1,0 +2,12 @@
+Wed Mar 18 11:29:15 UTC 2020 - [email protected]
+
+- version update to 1.0.1
+ * Use README as the long description on PyPI. [Stavros Korokithakis]
+ * Drop support for Python before 3.5. [Stavros Korokithakis]
+ * Add simple command-line interface (#43) [Éric Araujo]
+ * Make encode and decode MSB-first (#36) [Keane Nguyen]
+ * Make the URL check more robust (fixes #32) [Stavros Korokithakis]
+- deleted patches
+ - shortuuid-no-pep8.patch (upstreamed)
+
+-------------------------------------------------------------------
Old:
----
shortuuid-0.5.0.tar.gz
shortuuid-no-pep8.patch
New:
----
shortuuid-1.0.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-shortuuid.spec ++++++
--- /var/tmp/diff_new_pack.0UxUFP/_old 2020-03-19 19:53:50.060276697 +0100
+++ /var/tmp/diff_new_pack.0UxUFP/_new 2020-03-19 19:53:50.064276697 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-shortuuid
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,16 +17,16 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
Name: python-shortuuid
-Version: 0.5.0
+Version: 1.0.1
Release: 0
Summary: A generator library for concise, unambiguous and URL-safe UUIDs
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/stochastic-technologies/shortuuid/
Source:
https://files.pythonhosted.org/packages/source/s/shortuuid/shortuuid-%{version}.tar.gz
-# https://github.com/skorokithakis/shortuuid/issues/38
-Patch0: shortuuid-no-pep8.patch
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@@ -40,7 +40,6 @@
%prep
%setup -q -n shortuuid-%{version}
-%patch0 -p1
%build
%python_build
@@ -50,7 +49,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%python_exec setup.py test
+%pytest shortuuid/tests.py
%files %{python_files}
%doc README.rst
++++++ shortuuid-0.5.0.tar.gz -> shortuuid-1.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/PKG-INFO new/shortuuid-1.0.1/PKG-INFO
--- old/shortuuid-0.5.0/PKG-INFO 2017-02-19 15:25:04.000000000 +0100
+++ new/shortuuid-1.0.1/PKG-INFO 2020-03-06 12:49:32.000000000 +0100
@@ -1,18 +1,156 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: shortuuid
-Version: 0.5.0
+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: A library that generates short, pretty, unambiguous unique IDs by
using an extensive, case-sensitive alphabet and omitting similar-looking
letters and numbers.
+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 :: 2.5
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
+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-0.5.0/README.rst
new/shortuuid-1.0.1/README.rst
--- old/shortuuid-0.5.0/README.rst 2017-02-19 15:24:01.000000000 +0100
+++ new/shortuuid-1.0.1/README.rst 2020-03-06 12:05:05.000000000 +0100
@@ -19,7 +19,7 @@
To install ``shortuuid`` you need:
-* Python 2.5 or later in the 2.x line (earlier than 2.6 not tested).
+* 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:
@@ -50,7 +50,7 @@
>>> shortuuid.uuid(name="http://example.com")
'c8sh5y9hdSMS6zVnrvf53T'
-You can also generate a cryptographically secure random string (using
+You can also generate a cryptographically secure random string (using
`os.urandom()`, internally) with:
>>> shortuuid.ShortUUID().random(length=22)
@@ -107,6 +107,31 @@
>>> 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
-------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/setup.cfg
new/shortuuid-1.0.1/setup.cfg
--- old/shortuuid-0.5.0/setup.cfg 2017-02-19 15:25:04.000000000 +0100
+++ new/shortuuid-1.0.1/setup.cfg 2020-03-06 12:49:32.000000000 +0100
@@ -1,8 +1,18 @@
-[semantic_release]
-version_variable = shortuuid/__init__.py:__version__
+[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
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/setup.py new/shortuuid-1.0.1/setup.py
--- old/shortuuid-0.5.0/setup.py 2017-02-19 15:24:01.000000000 +0100
+++ new/shortuuid-1.0.1/setup.py 2020-03-06 12:48:29.000000000 +0100
@@ -1,18 +1,18 @@
#!/usr/bin/env python
-
import sys
-from shortuuid import __version__
-assert sys.version >= '2.5', "Requires Python v2.5 or above."
+
from setuptools import setup
+from shortuuid import __version__
+
+assert sys.version >= "3.5", "Requires Python v3.5 or above."
+
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
- "Programming Language :: Python :: 2.5",
- "Programming Language :: Python :: 2.6",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3.2",
- "Programming Language :: Python :: 3.3",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
"Topic :: Software Development :: Libraries :: Python Modules",
]
@@ -22,15 +22,12 @@
author="Stochastic Technologies",
author_email="[email protected]",
url="https://github.com/stochastic-technologies/shortuuid/",
- description="A generator library for concise, "
- "unambiguous and URL-safe UUIDs.",
- long_description="A library that generates short, pretty, "
- "unambiguous unique IDs "
- "by using an extensive, case-sensitive alphabet and omitting "
- "similar-looking letters and numbers.",
+ 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=['pep8'],
+ test_suite="shortuuid.tests",
+ tests_require=[],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/shortuuid/__init__.py
new/shortuuid-1.0.1/shortuuid/__init__.py
--- old/shortuuid-0.5.0/shortuuid/__init__.py 2017-02-19 15:24:39.000000000
+0100
+++ new/shortuuid-1.0.1/shortuuid/__init__.py 2020-03-06 12:45:51.000000000
+0100
@@ -1,11 +1,10 @@
-from shortuuid.main import (
- encode,
- decode,
- uuid,
- random,
- get_alphabet,
- set_alphabet,
- ShortUUID,
-)
+# 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
-__version__ = '0.5.0'
+__version__ = "1.0.1"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/shortuuid/__main__.py
new/shortuuid-1.0.1/shortuuid/__main__.py
--- old/shortuuid-0.5.0/shortuuid/__main__.py 1970-01-01 01:00:00.000000000
+0100
+++ new/shortuuid-1.0.1/shortuuid/__main__.py 2020-03-05 14:06:09.000000000
+0100
@@ -0,0 +1,4 @@
+from .main import uuid
+
+if __name__ == "__main__":
+ print(uuid())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/shortuuid/main.py
new/shortuuid-1.0.1/shortuuid/main.py
--- old/shortuuid-0.5.0/shortuuid/main.py 2017-02-19 15:24:01.000000000
+0100
+++ new/shortuuid-1.0.1/shortuuid/main.py 2020-03-06 12:11:07.000000000
+0100
@@ -1,5 +1,4 @@
""" Concise UUID generation. """
-
import binascii
import math
import os
@@ -9,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 = ""
alpha_len = len(alphabet)
@@ -18,16 +18,17 @@
if padding:
remainder = max(padding - len(output), 0)
output = output + alphabet[0] * remainder
- return output
+ return output[::-1]
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
alpha_len = len(alphabet)
- for char in string[::-1]:
+ for char in string:
number = number * alpha_len + alphabet.index(char)
return number
@@ -35,8 +36,7 @@
class ShortUUID(object):
def __init__(self, alphabet=None):
if alphabet is None:
- alphabet = list("23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
- "abcdefghijkmnopqrstuvwxyz")
+ alphabet = list("23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
"abcdefghijkmnopqrstuvwxyz")
self.set_alphabet(alphabet)
@@ -50,20 +50,27 @@
def encode(self, uuid, pad_length=None):
"""
- Encodes a UUID into a string (LSB first) according to the alphabet
- If leftmost (MSB) bits 0, string might be shorter
+ Encode a UUID into a string (LSB first) according to the alphabet
+
+ If leftmost (MSB) bits are 0, the string might be shorter.
"""
if pad_length is None:
pad_length = self._length
return int_to_string(uuid.int, self._alphabet, padding=pad_length)
- def decode(self, string):
+ def decode(self, string, legacy=False):
"""
- Decodes a string according to the current alphabet into a UUID
+ Decode a string according to the current alphabet into a UUID
Raises ValueError when encountering illegal characters
- or too long string
+ 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.
"""
+ if legacy:
+ string = string[::-1]
return _uu.UUID(int=string_to_int(string, self._alphabet))
def uuid(self, name=None, pad_length=None):
@@ -78,12 +85,12 @@
# If no name is given, generate a random UUID.
if name is None:
- uuid = _uu.uuid4()
- elif "http" not in name.lower():
- uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
+ u = _uu.uuid4()
+ elif name.lower().startswith(("http://", "https://")):
+ u = _uu.uuid5(_uu.NAMESPACE_URL, name)
else:
- uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)
- return self.encode(uuid, pad_length)
+ u = _uu.uuid5(_uu.NAMESPACE_DNS, name)
+ return self.encode(u, pad_length)
def random(self, length=None):
"""
@@ -94,13 +101,11 @@
length = self._length
random_num = int(binascii.b2a_hex(os.urandom(length)), 16)
- return int_to_string(
- random_num, self._alphabet, padding=length
- )[:length]
+ return int_to_string(random_num, self._alphabet,
padding=length)[:length]
def get_alphabet(self):
"""Return the current alphabet used for new UUIDs."""
- return ''.join(self._alphabet)
+ return "".join(self._alphabet)
def set_alphabet(self, alphabet):
"""Set the alphabet to be used for new UUIDs."""
@@ -112,8 +117,7 @@
self._alphabet = new_alphabet
self._alpha_len = len(self._alphabet)
else:
- raise ValueError("Alphabet with more than "
- "one unique symbols required.")
+ raise ValueError("Alphabet with more than " "one unique symbols
required.")
def encoded_length(self, num_bytes=16):
"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/shortuuid/tests.py
new/shortuuid-1.0.1/shortuuid/tests.py
--- old/shortuuid-0.5.0/shortuuid/tests.py 2017-02-19 15:24:01.000000000
+0100
+++ new/shortuuid-1.0.1/shortuuid/tests.py 2020-03-06 12:11:07.000000000
+0100
@@ -2,15 +2,20 @@
import string
import sys
import unittest
-import pep8
from collections import defaultdict
+from uuid import UUID
+from uuid import uuid4
-from uuid import UUID, uuid4
+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
sys.path.insert(0, os.path.abspath(__file__ + "/../.."))
-from shortuuid.main import * # noqa
-
class LegacyShortUUIDTest(unittest.TestCase):
def test_generation(self):
@@ -20,12 +25,12 @@
self.assertTrue(20 < len(uuid("example.com/")) < 24)
def test_encoding(self):
- u = UUID('{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}')
- self.assertEqual(encode(u), "bYRT25J5s7Bniqr4b58cXC")
+ u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+ self.assertEqual(encode(u), "CXc85b4rqinB7s5J52TRYb")
def test_decoding(self):
- u = UUID('{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}')
- self.assertEqual(decode("bYRT25J5s7Bniqr4b58cXC"), u)
+ u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+ self.assertEqual(decode("CXc85b4rqinB7s5J52TRYb"), u)
def test_alphabet(self):
backup_alphabet = get_alphabet()
@@ -69,13 +74,13 @@
def test_encoding(self):
su = ShortUUID()
- u = UUID('{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}')
- self.assertEqual(su.encode(u), "bYRT25J5s7Bniqr4b58cXC")
+ u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+ self.assertEqual(su.encode(u), "CXc85b4rqinB7s5J52TRYb")
def test_decoding(self):
su = ShortUUID()
- u = UUID('{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}')
- self.assertEqual(su.decode("bYRT25J5s7Bniqr4b58cXC"), u)
+ u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
+ self.assertEqual(su.decode("CXc85b4rqinB7s5J52TRYb"), u)
def test_random(self):
su = ShortUUID()
@@ -112,8 +117,7 @@
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)
@@ -125,16 +129,6 @@
su4 = ShortUUID()
self.assertEqual(su4.encoded_length(num_bytes=8), 11)
- def test_pep8(self):
- pep8style = pep8.StyleGuide([['statistics', True],
- ['show-sources', True],
- ['repeat', True],
- ['paths', [os.path.dirname(
- os.path.abspath(__file__))]]],
- parse_argv=False)
- report = pep8style.check_files()
- assert report.total_errors == 0
-
class ShortUUIDPaddingTest(unittest.TestCase):
def test_padding(self):
@@ -177,5 +171,5 @@
self.assertEqual(uid_lengths[uid_length], num_iterations)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/shortuuid-0.5.0/shortuuid.egg-info/PKG-INFO
new/shortuuid-1.0.1/shortuuid.egg-info/PKG-INFO
--- old/shortuuid-0.5.0/shortuuid.egg-info/PKG-INFO 2017-02-19
15:25:04.000000000 +0100
+++ new/shortuuid-1.0.1/shortuuid.egg-info/PKG-INFO 2020-03-06
12:49:32.000000000 +0100
@@ -1,18 +1,156 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: shortuuid
-Version: 0.5.0
+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: A library that generates short, pretty, unambiguous unique IDs by
using an extensive, case-sensitive alphabet and omitting similar-looking
letters and numbers.
+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 :: 2.5
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
+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-0.5.0/shortuuid.egg-info/SOURCES.txt
new/shortuuid-1.0.1/shortuuid.egg-info/SOURCES.txt
--- old/shortuuid-0.5.0/shortuuid.egg-info/SOURCES.txt 2017-02-19
15:25:04.000000000 +0100
+++ new/shortuuid-1.0.1/shortuuid.egg-info/SOURCES.txt 2020-03-06
12:49:32.000000000 +0100
@@ -4,6 +4,7 @@
setup.cfg
setup.py
shortuuid/__init__.py
+shortuuid/__main__.py
shortuuid/main.py
shortuuid/tests.py
shortuuid.egg-info/PKG-INFO