|
1
|
3 |
|
from __future__ import (absolute_import, division, |
|
2
|
|
|
print_function, unicode_literals) |
|
3
|
|
|
|
|
4
|
3 |
|
import logging |
|
5
|
|
|
|
|
6
|
3 |
|
import click |
|
|
|
|
|
|
7
|
3 |
|
import semantic_version |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
3 |
|
from changes import attributes |
|
10
|
|
|
|
|
11
|
3 |
|
log = logging.getLogger(__name__) |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
3 |
|
def current_version(module_name): |
|
15
|
|
|
return attributes.extract_attribute(module_name, '__version__') |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
3 |
|
def get_new_version(module_name, current_version, no_input, |
|
|
|
|
|
|
19
|
|
|
major=False, minor=False, patch=False): |
|
20
|
|
|
|
|
21
|
|
|
proposed_new_version = increment( |
|
22
|
|
|
current_version, |
|
23
|
|
|
major=major, |
|
24
|
|
|
minor=minor, |
|
25
|
|
|
patch=patch |
|
26
|
|
|
) |
|
27
|
|
|
|
|
28
|
|
|
if no_input: |
|
29
|
|
|
new_version = proposed_new_version |
|
30
|
|
|
else: |
|
31
|
|
|
new_version = click.prompt( |
|
32
|
|
|
'What is the release version for "{0}" '.format(module_name), |
|
33
|
|
|
default=proposed_new_version |
|
34
|
|
|
) |
|
35
|
|
|
return new_version.strip() |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
3 |
|
def increment(version, major=False, minor=False, patch=True): |
|
39
|
|
|
""" |
|
40
|
|
|
Increment a semantic version |
|
41
|
|
|
|
|
42
|
|
|
:param version: str of the version to increment |
|
43
|
|
|
:param major: bool specifying major level version increment |
|
44
|
|
|
:param minor: bool specifying minor level version increment |
|
45
|
|
|
:param patch: bool specifying patch level version increment |
|
46
|
|
|
:return: str of the incremented version |
|
47
|
|
|
""" |
|
48
|
|
|
version = semantic_version.Version(version) |
|
49
|
|
|
if major: |
|
50
|
|
|
version.major += 1 |
|
51
|
|
|
version.minor = 0 |
|
52
|
|
|
version.patch = 0 |
|
53
|
|
|
elif minor: |
|
54
|
|
|
version.minor += 1 |
|
55
|
|
|
version.patch = 0 |
|
56
|
|
|
elif patch: |
|
57
|
|
|
version.patch += 1 |
|
58
|
|
|
|
|
59
|
|
|
return str(version) |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
3 |
|
def increment_version(context): |
|
63
|
|
|
"""Increments the __version__ attribute of your module's __init__.""" |
|
64
|
|
|
|
|
65
|
|
|
attributes.replace_attribute( |
|
66
|
|
|
context.module_name, |
|
67
|
|
|
'__version__', |
|
68
|
|
|
context.new_version, |
|
69
|
|
|
dry_run=context.dry_run) |
|
70
|
|
|
log.info('Bumped version from %s to %s' % (context.current_version, context.new_version)) |
|
|
|
|
|
|
71
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.