# Path: genotp.py
# def rndcaps(n):
#     """
#     Generates a string of random capital letters.
# 
#     Arguments:
#         n: Length of the output string.
# 
#     Returns:
#         A string of n random capital letters.
#     """
#     return "".join([choice(_CAPS) for c in range(n)])
# 
# def otp(n=65):
#     """
#     Return a one-time pad.
# 
#     Arguments:
#         n: number of lines in the key
# 
#     Returns:
#         n lines of 12 groups of 5 random capital letters.
#     """
#     lines = []
#     for num in range(1, n + 1):
#         i = [f"{num:02d} "]
#         i += [rndcaps(5) for j in range(0, 12)]
#         lines.append(" ".join(i))
#     return "\n".join(lines)
# 
# Path: genpw.py
# def shannon(n):
# def genpw(length, encoder):
# 
# Path: offsetsrt.py
# def str2ms(s):
#     """
#     Convert the time strings from an SRT file to milliseconds.
# 
#     Arguments:
#         s: A time value in the format HH:MM:SS,mmm where H, M, S and m are
#            digits.
# 
#     Returns:
#         The time string converted to an integer value in milliseconds.
#     """
#     s = s.strip()
#     time, ms = s.split(",")
#     h, m, s = time.split(":")
#     return int(ms) + 1000 * (int(s) + 60 * (int(m) + 60 * int(h)))
# 
# def ms2str(v):
#     """
#     Convert a time in milliseconds to a time string.
# 
#     Arguments:
#         v: a time in milliseconds.
# 
#     Returns:
#         A string in the format HH:MM:SS,mmm.
#     """
#     v, ms = divmod(v, 1000)
#     v, s = divmod(v, 60)
#     h, m = divmod(v, 60)
#     return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"


from collections import Counter
from genotp import rndcaps, otp
from genpw import roundup, genpw
from nospaces import fixname
from offsetsrt import str2ms, ms2str
#!/usr/bin/env python
# file: scripts-tests.py
# vim:fileencoding=utf-8:fdm=marker:ft=python
#
# Copyright © 2018 R.F. Smith <rsmith@xs4all.nl>.
# SPDX-License-Identifier: MIT
# Created: 2015-04-06T13:08:02+0200
# Last modified: 2019-07-27T15:11:11+0200
"""
Tests for functions in python files in the scripts directory.

To run the tests use: py.test -v scripts-tests.py
"""




def test_rndcaps():
    rv = rndcaps(20)
    assert len(rv) == 20
    assert all(j in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for j in rv)

# Path: genotp.py
# def rndcaps(n):
#     """
#     Generates a string of random capital letters.
# 
#     Arguments:
#         n: Length of the output string.
# 
#     Returns:
#         A string of n random capital letters.
#     """
#     return "".join([choice(_CAPS) for c in range(n)])
# 
# def otp(n=65):
#     """
#     Return a one-time pad.
# 
#     Arguments:
#         n: number of lines in the key
# 
#     Returns:
#         n lines of 12 groups of 5 random capital letters.
#     """
#     lines = []
#     for num in range(1, n + 1):
#         i = [f"{num:02d} "]
#         i += [rndcaps(5) for j in range(0, 12)]
#         lines.append(" ".join(i))
#     return "\n".join(lines)
# 
# Path: genpw.py
# def shannon(n):
# def genpw(length, encoder):
# 
# Path: offsetsrt.py
# def str2ms(s):
#     """
#     Convert the time strings from an SRT file to milliseconds.
# 
#     Arguments:
#         s: A time value in the format HH:MM:SS,mmm where H, M, S and m are
#            digits.
# 
#     Returns:
#         The time string converted to an integer value in milliseconds.
#     """
#     s = s.strip()
#     time, ms = s.split(",")
#     h, m, s = time.split(":")
#     return int(ms) + 1000 * (int(s) + 60 * (int(m) + 60 * int(h)))
# 
# def ms2str(v):
#     """
#     Convert a time in milliseconds to a time string.
# 
#     Arguments:
#         v: a time in milliseconds.
# 
#     Returns:
#         A string in the format HH:MM:SS,mmm.
#     """
#     v, ms = divmod(v, 1000)
#     v, s = divmod(v, 60)
#     h, m = divmod(v, 60)
#     return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"


# Path: scripts-tests.py
from collections import Counter
from genotp import rndcaps, otp
from genpw import roundup, genpw
from nospaces import fixname
from offsetsrt import str2ms, ms2str

#!/usr/bin/env python
# file: scripts-tests.py
# vim:fileencoding=utf-8:fdm=marker:ft=python
#
# Copyright © 2018 R.F. Smith <rsmith@xs4all.nl>.
# SPDX-License-Identifier: MIT
# Created: 2015-04-06T13:08:02+0200
# Last modified: 2019-07-27T15:11:11+0200
"""
Tests for functions in python files in the scripts directory.

To run the tests use: py.test -v scripts-tests.py
"""




def test_rndcaps():
    rv = rndcaps(20)
    assert len(rv) == 20
    assert all(j in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for j in rv)

    v = Counter(rndcaps(100000)).values()