|
1
|
3 |
|
from os.path import exists, join, curdir |
|
2
|
3 |
|
import io |
|
3
|
|
|
|
|
4
|
3 |
|
import click |
|
|
|
|
|
|
5
|
3 |
|
import giturlparse |
|
|
|
|
|
|
6
|
3 |
|
from path import Path |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
3 |
|
from plumbum.cmd import git |
|
|
|
|
|
|
9
|
3 |
|
import toml |
|
|
|
|
|
|
10
|
3 |
|
from invoke import run |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
3 |
|
CONFIG_FILE = '.changes.toml' |
|
13
|
3 |
|
CONFIG_FILES = [ |
|
14
|
|
|
'.changes.toml', |
|
15
|
|
|
'pyproject.toml', |
|
16
|
|
|
'setup.cfg', |
|
17
|
|
|
] |
|
18
|
3 |
|
DOCS = [ |
|
19
|
|
|
'CHANGELOG.md', |
|
20
|
|
|
'README.md', |
|
21
|
|
|
] |
|
22
|
3 |
|
DEFAULTS = { |
|
23
|
|
|
'changelog': 'CHANGELOG.md', |
|
24
|
|
|
'readme': 'README.md', |
|
25
|
|
|
'github_auth_token': None, |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
3 |
|
class Config: |
|
30
|
3 |
|
test_command = None |
|
31
|
3 |
|
pypi = None |
|
32
|
3 |
|
skip_changelog = None |
|
33
|
3 |
|
changelog_content = None |
|
34
|
3 |
|
repo = None |
|
35
|
|
|
|
|
36
|
3 |
|
def __init__(self, module_name, dry_run, debug, no_input, requirements, |
|
37
|
|
|
new_version, current_version, repo_url, version_prefix): |
|
38
|
3 |
|
self.module_name = module_name |
|
39
|
|
|
# module_name => project_name => curdir |
|
40
|
3 |
|
self.dry_run = dry_run |
|
41
|
3 |
|
self.debug = debug |
|
42
|
3 |
|
self.no_input = no_input |
|
43
|
3 |
|
self.requirements = requirements |
|
44
|
3 |
|
self.new_version = ( |
|
45
|
|
|
version_prefix + new_version |
|
46
|
|
|
if version_prefix |
|
47
|
|
|
else new_version |
|
48
|
|
|
) |
|
49
|
3 |
|
self.current_version = current_version |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
3 |
|
def project_config(): |
|
53
|
|
|
"""Deprecated""" |
|
54
|
3 |
|
project_name = curdir |
|
55
|
|
|
|
|
56
|
3 |
|
config_path = Path(join(project_name, CONFIG_FILE)) |
|
57
|
|
|
|
|
58
|
3 |
|
if not exists(config_path): |
|
59
|
3 |
|
store_settings(DEFAULTS.copy()) |
|
60
|
3 |
|
return DEFAULTS |
|
61
|
|
|
|
|
62
|
3 |
|
return toml.load(io.open(config_path)) or {} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
3 |
|
def load_settings(): |
|
66
|
3 |
|
return project_config() |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
3 |
|
def store_settings(settings): |
|
70
|
3 |
|
config_path = Path(join(curdir, CONFIG_FILE)) |
|
71
|
|
|
|
|
72
|
3 |
|
with click.open_file(config_path, 'w') as f: |
|
|
|
|
|
|
73
|
3 |
|
f.write(toml.dumps(settings)) |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
# def bumpversion_settings(): |
|
77
|
|
|
# pass |
|
78
|
|
|
# def towncrier_settings(): |
|
79
|
|
|
# fn = join(curdir, "pyproject.toml") |
|
80
|
|
|
# if not exists(fn): |
|
81
|
|
|
# return None |
|
82
|
|
|
# with open(fn, 'r') as conffile: |
|
83
|
|
|
# config = toml.load(conffile) |
|
84
|
|
|
# |
|
85
|
|
|
# if 'tool' not in config or 'package' not in config['tool']['towncrier']: |
|
86
|
|
|
# raise NotConfigured( |
|
87
|
|
|
# 'No [tool.towncrier] section or ' |
|
88
|
|
|
# "the towncrier section has no required 'package' key." |
|
89
|
|
|
# ) |
|
90
|
|
|
# return config['tool']['towncrier'] |
|
91
|
|
|
|
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.