|
2 | 2 | import datetime
|
3 | 3 | import warnings
|
4 | 4 | import re
|
5 |
| -from itertools import chain, repeat, islice |
6 | 5 |
|
7 | 6 | from .config import Configuration
|
8 | 7 | from .utils import trace, string_types, utc
|
|
16 | 15 | SEMVER_LEN = 3
|
17 | 16 |
|
18 | 17 |
|
19 |
| -def _pad(iterable, size, padding=None): |
20 |
| - padded = chain(iterable, repeat(padding)) |
21 |
| - return list(islice(padded, size)) |
22 |
| - |
23 |
| - |
24 | 18 | def _parse_version_tag(tag, config):
|
25 | 19 | tagstring = tag if not isinstance(tag, string_types) else str(tag)
|
26 | 20 | match = config.tag_regex.match(tagstring)
|
@@ -249,12 +243,14 @@ def guess_next_dev_version(version):
|
249 | 243 |
|
250 | 244 |
|
251 | 245 | def guess_next_simple_semver(version, retain, increment=True):
|
252 |
| - parts = map(int, str(version).split(".")) |
253 |
| - parts = _pad(parts, retain, 0) |
| 246 | + parts = [int(i) for i in str(version).split(".")[:retain]] |
| 247 | + while len(parts) < retain: |
| 248 | + parts.append(0) |
254 | 249 | if increment:
|
255 | 250 | parts[-1] += 1
|
256 |
| - parts = _pad(parts, SEMVER_LEN, 0) |
257 |
| - return ".".join(map(str, parts)) |
| 251 | + while len(parts) < SEMVER_LEN: |
| 252 | + parts.append(0) |
| 253 | + return ".".join(str(i) for i in parts) |
258 | 254 |
|
259 | 255 |
|
260 | 256 | def simplified_semver_version(version):
|
|
0 commit comments