mpd-kit 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mpd_kit-0.0.1/PKG-INFO +3 -0
- mpd_kit-0.0.1/README.md +28 -0
- mpd_kit-0.0.1/setup.cfg +4 -0
- mpd_kit-0.0.1/setup.py +14 -0
- mpd_kit-0.0.1/src/mpd_kit/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/argparser/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/argparser/argconditions.py +2 -0
- mpd_kit-0.0.1/src/mpd_kit/argparser/argparse.py +97 -0
- mpd_kit-0.0.1/src/mpd_kit/argparser/argvars.py +10 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/BuildArguments.py +5 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/Configuration.py +58 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/Project.py +102 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/ValueSignature.py +11 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/exceptions/SecondNonRecurringValue.py +1 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/exceptions/SkippedRequiredValue.py +1 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/exceptions/SystemCommandFailed.py +1 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/exceptions/UnknownValue.py +1 -0
- mpd_kit-0.0.1/src/mpd_kit/classes/exceptions/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/cli.py +60 -0
- mpd_kit-0.0.1/src/mpd_kit/corelibs/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/corelibs/build_functions.py +17 -0
- mpd_kit-0.0.1/src/mpd_kit/corelibs/configparse/__init__.py +0 -0
- mpd_kit-0.0.1/src/mpd_kit/corelibs/configparse/parser.py +30 -0
- mpd_kit-0.0.1/src/mpd_kit/vars.py +1 -0
- mpd_kit-0.0.1/src/mpd_kit.egg-info/PKG-INFO +3 -0
- mpd_kit-0.0.1/src/mpd_kit.egg-info/SOURCES.txt +28 -0
- mpd_kit-0.0.1/src/mpd_kit.egg-info/dependency_links.txt +1 -0
- mpd_kit-0.0.1/src/mpd_kit.egg-info/entry_points.txt +2 -0
- mpd_kit-0.0.1/src/mpd_kit.egg-info/top_level.txt +1 -0
mpd_kit-0.0.1/PKG-INFO
ADDED
mpd_kit-0.0.1/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# MPD-Kit
|
|
2
|
+
|
|
3
|
+
Welcome to MPD-Kit official repository!
|
|
4
|
+
|
|
5
|
+
MPD stands for "Multi-Platform Development" and solves a lot of problems that can happen while you're compiling your application.
|
|
6
|
+
|
|
7
|
+
This program is on development stage right now. If you want to support development, please give this project a star :)
|
|
8
|
+
|
|
9
|
+
## Quick overview
|
|
10
|
+
|
|
11
|
+
MPD-Kit is useful tool to automate compiling Python code with `pyinstaller`. Compilation process looks like using Meson, CMake and tools like these.
|
|
12
|
+
|
|
13
|
+
First, MPD-Kit will create a virtual environment for project build and install required libraries from requirements.txt.
|
|
14
|
+
After installation is done, builder starts the `pyinstaller` command for files that you specified in your config file.
|
|
15
|
+
|
|
16
|
+
The latest step is copying binary files from cache to `dist` - and process is done!
|
|
17
|
+
|
|
18
|
+
## About MPD-Clicks
|
|
19
|
+
|
|
20
|
+
MPD-Clicks is the GUI application that allows you to use the same functions as from MPD-CLI with more intuitive way than MPD-CLI.
|
|
21
|
+
You can look at this project at https://github.com/VladosNX/MPD-Clicks
|
|
22
|
+
|
|
23
|
+
## Future features
|
|
24
|
+
|
|
25
|
+
### 1. Cross-compiling
|
|
26
|
+
|
|
27
|
+
Since `pyinstaller` can't cross-compile applications, MPD-Kit will solve this problem with simple and minimalistic virtual machines.
|
|
28
|
+
Program will copy your project source files into required VM and start cross compilers there and copy files to certain folder.
|
mpd_kit-0.0.1/setup.cfg
ADDED
mpd_kit-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from src.mpd_kit.vars import VERSION
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="mpd_kit",
|
|
6
|
+
version=VERSION,
|
|
7
|
+
packages=find_packages(where='src'),
|
|
8
|
+
package_dir={'': 'src'},
|
|
9
|
+
entry_points={
|
|
10
|
+
"console_scripts": [
|
|
11
|
+
"mpd-cli=mpd_kit.cli:main"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import mpd_kit.argparser.argvars as argvars
|
|
3
|
+
import mpd_kit.argparser.argconditions as argconditions
|
|
4
|
+
|
|
5
|
+
# Input dictionary has information about all available options.
|
|
6
|
+
# Options are stored in order like:
|
|
7
|
+
# [ type: int, id: str, required: bool|function, short: str|None, has_value: bool, order: int|None ]
|
|
8
|
+
# If you specified a function to 'required' field, it will be executed after arguments parsing is done to check if argument should be required based on context
|
|
9
|
+
# long and short options aren't required if you didn't set type to '1'
|
|
10
|
+
# order is used for ordinal arguments
|
|
11
|
+
|
|
12
|
+
inputs = [
|
|
13
|
+
[ argvars.TYPE_ORDINAL, 'mode', argconditions.isModeRequired, None, True, 0 ],
|
|
14
|
+
[ argvars.TYPE_DOUBLEDASH, 'help', False, None, False, None ],
|
|
15
|
+
[ argvars.TYPE_DOUBLEDASH, 'verbose', False, 'v', False, None ],
|
|
16
|
+
[ argvars.TYPE_DOUBLEDASH, 'pythoncmd', False, 'p', True, None ]
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
def _findByDoubleDash(value: str):
|
|
20
|
+
for option in inputs:
|
|
21
|
+
if option[argvars.ARG_TYPE] != argvars.TYPE_DOUBLEDASH: continue
|
|
22
|
+
if value.lstrip('-') == option[argvars.ARG_ID]: return option
|
|
23
|
+
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
def _findBySingleDash(value: str):
|
|
27
|
+
for option in inputs:
|
|
28
|
+
if option[argvars.ARG_TYPE] != argvars.TYPE_DOUBLEDASH: continue
|
|
29
|
+
if value.lstrip('-') == option[argvars.ARG_SHORT]: return option
|
|
30
|
+
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
def _findByOrdinal(index: int):
|
|
34
|
+
for option in inputs:
|
|
35
|
+
if option[argvars.ARG_TYPE] != argvars.TYPE_ORDINAL: continue
|
|
36
|
+
if index == option[argvars.ARG_ORDER]: return option
|
|
37
|
+
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
def _findById(arg_id: str):
|
|
41
|
+
for option in inputs:
|
|
42
|
+
if option[argvars.ARG_ID] == arg_id: return option
|
|
43
|
+
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
def parse(args):
|
|
47
|
+
ordinalIndex = 0
|
|
48
|
+
options = {}
|
|
49
|
+
# Filling options dictionary with zero-values
|
|
50
|
+
for option in inputs:
|
|
51
|
+
options[option[argvars.ARG_ID]] = None
|
|
52
|
+
|
|
53
|
+
assignNextTo = None
|
|
54
|
+
for arg in args[1:]:
|
|
55
|
+
if len(arg) == 0: continue
|
|
56
|
+
optionSignature = None
|
|
57
|
+
|
|
58
|
+
if assignNextTo:
|
|
59
|
+
options[assignNextTo] = arg
|
|
60
|
+
assignNextTo = None
|
|
61
|
+
continue
|
|
62
|
+
|
|
63
|
+
if arg[0] == '-':
|
|
64
|
+
if arg[1] == '-':
|
|
65
|
+
# user specified double-dash argument
|
|
66
|
+
optionSignature = _findByDoubleDash(arg)
|
|
67
|
+
else:
|
|
68
|
+
# user specified single-dash argument
|
|
69
|
+
optionSignature = _findBySingleDash(arg)
|
|
70
|
+
else:
|
|
71
|
+
# user specified ordinal argument
|
|
72
|
+
optionSignature = _findByOrdinal(ordinalIndex)
|
|
73
|
+
ordinalIndex += 1
|
|
74
|
+
|
|
75
|
+
if not optionSignature:
|
|
76
|
+
print('Incorrect argument :( See --help', file=sys.stderr)
|
|
77
|
+
sys.exit(1)
|
|
78
|
+
elif optionSignature[argvars.ARG_TYPE] == argvars.TYPE_ORDINAL:
|
|
79
|
+
options[optionSignature[argvars.ARG_ID]] = arg
|
|
80
|
+
elif optionSignature[argvars.ARG_HAS_VALUE]:
|
|
81
|
+
assignNextTo = optionSignature[argvars.ARG_ID]
|
|
82
|
+
else:
|
|
83
|
+
options[optionSignature[argvars.ARG_ID]] = True
|
|
84
|
+
|
|
85
|
+
for option in inputs:
|
|
86
|
+
if options[option[argvars.ARG_ID]] is None:
|
|
87
|
+
required = False
|
|
88
|
+
if option[argvars.ARG_REQUIRED] is bool and option[argvars.ARG_REQUIRED]:
|
|
89
|
+
required = True
|
|
90
|
+
elif callable(option[argvars.ARG_REQUIRED]):
|
|
91
|
+
required = option[argvars.ARG_REQUIRED](options)
|
|
92
|
+
|
|
93
|
+
if required:
|
|
94
|
+
print(f'You skipped required argument called {option[argvars.ARG_ID]}!', file=sys.stderr)
|
|
95
|
+
sys.exit(1)
|
|
96
|
+
|
|
97
|
+
return options
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from mpd_kit.classes.exceptions.SecondNonRecurringValue import SecondNonRecurringValue
|
|
2
|
+
from mpd_kit.classes.exceptions.UnknownValue import UnknownValue
|
|
3
|
+
from mpd_kit.classes.exceptions.SkippedRequiredValue import SkipperRequiredValue
|
|
4
|
+
from mpd_kit.classes.ValueSignature import ValueSignature
|
|
5
|
+
|
|
6
|
+
ARG_KEY = 0
|
|
7
|
+
ARG_VALUE = 1
|
|
8
|
+
|
|
9
|
+
class Configuration:
|
|
10
|
+
values = []
|
|
11
|
+
|
|
12
|
+
value_signatures = [
|
|
13
|
+
ValueSignature('PRETTY', 'Pretty Name', False, True),
|
|
14
|
+
ValueSignature('VERSION', 'Version', False, True),
|
|
15
|
+
ValueSignature('BRIEF', 'Description', False, True),
|
|
16
|
+
ValueSignature('ENTRY', 'Entry File', True, True),
|
|
17
|
+
ValueSignature('BASEFLAGS', 'Base Compiler Flags', False, False),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
def getValueSignature(self, key: str):
|
|
21
|
+
for item in self.value_signatures:
|
|
22
|
+
if item.key == key:
|
|
23
|
+
return item
|
|
24
|
+
|
|
25
|
+
return None
|
|
26
|
+
|
|
27
|
+
def getValue(self, key: str):
|
|
28
|
+
for value in self.values:
|
|
29
|
+
if value[ARG_KEY] == key:
|
|
30
|
+
return value[ARG_VALUE]
|
|
31
|
+
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
def getRecurringValues(self, key):
|
|
35
|
+
result = []
|
|
36
|
+
|
|
37
|
+
for item in self.values:
|
|
38
|
+
if item[ARG_KEY] == key:
|
|
39
|
+
result.append(item[ARG_VALUE])
|
|
40
|
+
|
|
41
|
+
return result
|
|
42
|
+
|
|
43
|
+
def setValue(self, key: str, value: str):
|
|
44
|
+
signature = self.getValueSignature(key)
|
|
45
|
+
|
|
46
|
+
if not signature.recurring:
|
|
47
|
+
if self.getValue(key):
|
|
48
|
+
raise SecondNonRecurringValue(key)
|
|
49
|
+
|
|
50
|
+
if not signature:
|
|
51
|
+
raise UnknownValue(key)
|
|
52
|
+
|
|
53
|
+
self.values.append([key, value])
|
|
54
|
+
|
|
55
|
+
def validateRequired(self):
|
|
56
|
+
for signature in self.value_signatures:
|
|
57
|
+
if signature.required and not self.getValue(signature.key):
|
|
58
|
+
raise SkipperRequiredValue(signature.key)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from mpd_kit.classes.Configuration import Configuration
|
|
2
|
+
from mpd_kit.classes.exceptions.SystemCommandFailed import SystemCommandFailed
|
|
3
|
+
from mpd_kit.classes.BuildArguments import BuildArguments
|
|
4
|
+
import mpd_kit.corelibs.configparse.parser as configparser
|
|
5
|
+
import mpd_kit.corelibs.build_functions as build_functions
|
|
6
|
+
import mpd_kit.vars as vars
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
|
|
10
|
+
class Project:
|
|
11
|
+
path = ''
|
|
12
|
+
config = Configuration()
|
|
13
|
+
|
|
14
|
+
def __init__(self, path):
|
|
15
|
+
self.path = path
|
|
16
|
+
|
|
17
|
+
config = configparser.parse_config(self.path)
|
|
18
|
+
|
|
19
|
+
def build(self, log, next_step, arguments: BuildArguments):
|
|
20
|
+
# progress_funcs should accept 2 arguments - category and info
|
|
21
|
+
# category is a type of information - info, warn, done, error, cmd
|
|
22
|
+
log('info', f'Running MPD-Kit {vars.VERSION}, task: letsgo')
|
|
23
|
+
python_cmd = 'python3' if arguments.python_cmd is None else arguments.python_cmd
|
|
24
|
+
venv_path = 'mpd-venv'
|
|
25
|
+
log('info', f'Using {python_cmd} as Python executable')
|
|
26
|
+
log('info', f'Using {venv_path} as Python virtual environment')
|
|
27
|
+
|
|
28
|
+
# Step 1: Creating virtual environment
|
|
29
|
+
next_step(1, 'Creating virtual environment')
|
|
30
|
+
try:
|
|
31
|
+
build_functions.run_command(f"{python_cmd} -m venv {venv_path}")
|
|
32
|
+
except SystemCommandFailed:
|
|
33
|
+
log('error', f'Failed to create a virtual environment')
|
|
34
|
+
return False
|
|
35
|
+
log('done', 'Virtual environment created successfully')
|
|
36
|
+
|
|
37
|
+
old_path = os.environ['PATH']
|
|
38
|
+
log('info', f'Old PATH: {old_path}')
|
|
39
|
+
new_path = f"{os.path.abspath(self.path)}/{venv_path}/bin:{old_path}" # TODO: make this program working with absolute venv_path correctly
|
|
40
|
+
os.environ['PATH'] = new_path
|
|
41
|
+
log('info', f'New PATH: {new_path}')
|
|
42
|
+
log('done', f'Switched to virtual environment')
|
|
43
|
+
|
|
44
|
+
# Step 2: Installing libraries
|
|
45
|
+
next_step(2, 'Installing libraries')
|
|
46
|
+
if os.path.exists(f'{os.path.abspath(self.path)}/requirements.txt'):
|
|
47
|
+
try:
|
|
48
|
+
build_functions.run_command('pip install -r requirements.txt')
|
|
49
|
+
except SystemCommandFailed:
|
|
50
|
+
log('error', 'Failed to install libraries from requirements.txt')
|
|
51
|
+
return False
|
|
52
|
+
else:
|
|
53
|
+
log('warn', 'There is no requirements.txt, skipping libraries installation')
|
|
54
|
+
|
|
55
|
+
log('info', 'Installing pyinstaller')
|
|
56
|
+
try:
|
|
57
|
+
build_functions.run_command('pip install pyinstaller')
|
|
58
|
+
except SystemCommandFailed:
|
|
59
|
+
log('error', 'Failed to install pyinstaller')
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
log('done', 'All libraries installed successfully')
|
|
63
|
+
|
|
64
|
+
# Step 3: Compiling
|
|
65
|
+
next_step(3, 'Compiling')
|
|
66
|
+
builddir = os.path.join(os.path.abspath(self.path), 'mpd-files')
|
|
67
|
+
build_functions.recreate_dir(builddir)
|
|
68
|
+
log('done', f'Created directory "{builddir}"')
|
|
69
|
+
|
|
70
|
+
entries = self.config.getRecurringValues('ENTRY')
|
|
71
|
+
for file in entries:
|
|
72
|
+
log('info', f'Compiling {file}')
|
|
73
|
+
baseflags = self.config.getValue("BASEFLAGS")
|
|
74
|
+
baseflags = '' if not baseflags else baseflags
|
|
75
|
+
installation_command = f'cd {builddir} && pyinstaller -F {baseflags} ../{file}'
|
|
76
|
+
log('cmd', installation_command)
|
|
77
|
+
try:
|
|
78
|
+
build_functions.run_command(installation_command)
|
|
79
|
+
except SystemCommandFailed:
|
|
80
|
+
log('error', f'Failed to compile {file}')
|
|
81
|
+
return False
|
|
82
|
+
log('done', f'{file} compiled successfully')
|
|
83
|
+
|
|
84
|
+
# Step 4: Copying and cleaning
|
|
85
|
+
next_step(4, 'Copying and cleaning')
|
|
86
|
+
result_dir = os.path.join(os.path.abspath(self.path), 'mpd-dist')
|
|
87
|
+
log('info', f'Copying dist directory to {result_dir}')
|
|
88
|
+
build_functions.clear_dir(result_dir)
|
|
89
|
+
shutil.copytree(f'{builddir}/dist', result_dir)
|
|
90
|
+
log('done', f'dist directory copied')
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
shutil.rmtree(builddir)
|
|
94
|
+
shutil.rmtree(venv_path)
|
|
95
|
+
|
|
96
|
+
log('done', 'Compilation done!')
|
|
97
|
+
|
|
98
|
+
# at the end of executing
|
|
99
|
+
log('info', 'Switching back to old PATH')
|
|
100
|
+
os.environ['PATH'] = old_path
|
|
101
|
+
|
|
102
|
+
return True
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class ValueSignature:
|
|
2
|
+
key = None
|
|
3
|
+
pretty_name = None
|
|
4
|
+
recurring = None
|
|
5
|
+
required = False
|
|
6
|
+
|
|
7
|
+
def __init__(self, key: str, pretty_name: str, recurring: bool, required: bool):
|
|
8
|
+
self.key = key
|
|
9
|
+
self.pretty_name = pretty_name
|
|
10
|
+
self.recurring = recurring
|
|
11
|
+
self.required = required
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class SecondNonRecurringValue(Exception): pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class SkipperRequiredValue(Exception): pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class SystemCommandFailed(Exception): pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class UnknownValue(Exception): pass
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import mpd_kit.vars as vars
|
|
2
|
+
import sys
|
|
3
|
+
import mpd_kit.argparser.argparse as argparse
|
|
4
|
+
from mpd_kit.classes.Project import Project
|
|
5
|
+
from mpd_kit.classes.BuildArguments import BuildArguments
|
|
6
|
+
|
|
7
|
+
def show_log(category, info):
|
|
8
|
+
colors = {
|
|
9
|
+
'info': 4,
|
|
10
|
+
'warn': 3,
|
|
11
|
+
'error': 1,
|
|
12
|
+
'done': 2,
|
|
13
|
+
'cmd': 5
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
print(f"[\x1b[3{colors[category]}m{category.ljust(5)}\x1b[0m] {info}")
|
|
17
|
+
|
|
18
|
+
def show_step(step, title):
|
|
19
|
+
print(f'+===== STEP {step}')
|
|
20
|
+
print(f'| {title}')
|
|
21
|
+
print(f'+===========')
|
|
22
|
+
|
|
23
|
+
def main():
|
|
24
|
+
arguments = argparse.parse(sys.argv)
|
|
25
|
+
|
|
26
|
+
if arguments['help']:
|
|
27
|
+
print(f"MPD-Kit {vars.VERSION}")
|
|
28
|
+
print("")
|
|
29
|
+
print("Made by VladosNX. Follow me on my GitHub! https://github.com/VladosNX")
|
|
30
|
+
print("")
|
|
31
|
+
print("Basic usage:")
|
|
32
|
+
print(" mpd-cli <mode> [--help] [--verbose / -v]")
|
|
33
|
+
print("")
|
|
34
|
+
print("mode: Which action MPD-Cli has to do")
|
|
35
|
+
print("--help: Show this message")
|
|
36
|
+
print("--verbose or -v: Show more information about current task")
|
|
37
|
+
print("")
|
|
38
|
+
print("Available modes:")
|
|
39
|
+
print("")
|
|
40
|
+
print("letsgo: Start compiling process with default configuration")
|
|
41
|
+
print("validate: Check is your config file correct and show information about this project")
|
|
42
|
+
print("")
|
|
43
|
+
print("If you have some problems with MPD-CLI, please consider creating an issue on GitHub:")
|
|
44
|
+
print(" https://github.com/VladosNX/MPD-Kit/issues")
|
|
45
|
+
print("or consider using MPD-Clicks instead if you prefer GUI:")
|
|
46
|
+
print(" https://github.com/VladosNX/MPD-Clicks")
|
|
47
|
+
sys.exit()
|
|
48
|
+
|
|
49
|
+
project = Project('.')
|
|
50
|
+
|
|
51
|
+
if arguments['mode'] == 'validate':
|
|
52
|
+
for item in project.config.values:
|
|
53
|
+
print(f"{project.config.getValueSignature(item[0]).pretty_name}: {item[1]}")
|
|
54
|
+
elif arguments['mode'] == 'letsgo':
|
|
55
|
+
build_arguments = BuildArguments()
|
|
56
|
+
build_arguments.python_cmd = arguments['pythoncmd']
|
|
57
|
+
project.build(show_log, show_step, build_arguments)
|
|
58
|
+
|
|
59
|
+
if __name__ == '__main__':
|
|
60
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from mpd_kit.classes.exceptions.SystemCommandFailed import SystemCommandFailed
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
def run_command(command: str):
|
|
6
|
+
status = os.system(command)
|
|
7
|
+
if status != 0:
|
|
8
|
+
raise SystemCommandFailed([command, status])
|
|
9
|
+
|
|
10
|
+
def recreate_dir(name: str):
|
|
11
|
+
if os.path.exists(name):
|
|
12
|
+
shutil.rmtree(name)
|
|
13
|
+
os.mkdir(name)
|
|
14
|
+
|
|
15
|
+
def clear_dir(name: str):
|
|
16
|
+
if os.path.exists(name):
|
|
17
|
+
shutil.rmtree(name)
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from mpd_kit.classes.Configuration import Configuration
|
|
4
|
+
|
|
5
|
+
def parse_config(project='.'):
|
|
6
|
+
dotmpd_file = f'{project}/DOTMPD'
|
|
7
|
+
if not os.path.exists(dotmpd_file):
|
|
8
|
+
print('There is no DOTMPD file in your project.', file=sys.stderr)
|
|
9
|
+
sys.exit(1)
|
|
10
|
+
|
|
11
|
+
file = open(dotmpd_file, mode='r', encoding='utf-8')
|
|
12
|
+
content = file.read()
|
|
13
|
+
file.close()
|
|
14
|
+
|
|
15
|
+
lines = content.split('\n')
|
|
16
|
+
if len(lines) < 1 or lines[0] != 'DOTMPD1':
|
|
17
|
+
print('Your DOTMPD file beginning is incorrect.', file=sys.stderr)
|
|
18
|
+
sys.exit(1)
|
|
19
|
+
# TODO: call exception instead of quitting program
|
|
20
|
+
|
|
21
|
+
result = Configuration()
|
|
22
|
+
for line_raw in lines[1:]:
|
|
23
|
+
line = line_raw.lstrip().rstrip()
|
|
24
|
+
if line == '': continue
|
|
25
|
+
if line[0] == '#': continue
|
|
26
|
+
|
|
27
|
+
key, value = line.split('>')
|
|
28
|
+
result.setValue(key, value)
|
|
29
|
+
|
|
30
|
+
result.validateRequired()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '0.0.1'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
src/mpd_kit/__init__.py
|
|
4
|
+
src/mpd_kit/cli.py
|
|
5
|
+
src/mpd_kit/vars.py
|
|
6
|
+
src/mpd_kit.egg-info/PKG-INFO
|
|
7
|
+
src/mpd_kit.egg-info/SOURCES.txt
|
|
8
|
+
src/mpd_kit.egg-info/dependency_links.txt
|
|
9
|
+
src/mpd_kit.egg-info/entry_points.txt
|
|
10
|
+
src/mpd_kit.egg-info/top_level.txt
|
|
11
|
+
src/mpd_kit/argparser/__init__.py
|
|
12
|
+
src/mpd_kit/argparser/argconditions.py
|
|
13
|
+
src/mpd_kit/argparser/argparse.py
|
|
14
|
+
src/mpd_kit/argparser/argvars.py
|
|
15
|
+
src/mpd_kit/classes/BuildArguments.py
|
|
16
|
+
src/mpd_kit/classes/Configuration.py
|
|
17
|
+
src/mpd_kit/classes/Project.py
|
|
18
|
+
src/mpd_kit/classes/ValueSignature.py
|
|
19
|
+
src/mpd_kit/classes/__init__.py
|
|
20
|
+
src/mpd_kit/classes/exceptions/SecondNonRecurringValue.py
|
|
21
|
+
src/mpd_kit/classes/exceptions/SkippedRequiredValue.py
|
|
22
|
+
src/mpd_kit/classes/exceptions/SystemCommandFailed.py
|
|
23
|
+
src/mpd_kit/classes/exceptions/UnknownValue.py
|
|
24
|
+
src/mpd_kit/classes/exceptions/__init__.py
|
|
25
|
+
src/mpd_kit/corelibs/__init__.py
|
|
26
|
+
src/mpd_kit/corelibs/build_functions.py
|
|
27
|
+
src/mpd_kit/corelibs/configparse/__init__.py
|
|
28
|
+
src/mpd_kit/corelibs/configparse/parser.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mpd_kit
|