Passed
Push — master ( 5668a3...07978c )
by Konrad
08:41
created

get_database_parameter()   A

Complexity

Conditions 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
#!/usr/bin/env python3
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# -*- coding: future_fstrings -*-
3
4
import re
0 ignored issues
show
Unused Code introduced by
The import re seems to be unused.
Loading history...
5
import sys
0 ignored issues
show
Unused Code introduced by
The import sys seems to be unused.
Loading history...
6
7
from db_sync_tool.utility import mode, system, helper, output
0 ignored issues
show
Unused Code introduced by
Unused output imported from db_sync_tool.utility
Loading history...
8
9
10
def check_configuration(client):
11
    """
12
    Checking remote Laravel database configuration
13
    :param client: String
14
    :return:
15
    """
16
    _path = system.config[client]['path']
17
18
    system.config[client]['db'] = {
19
        'name': get_database_parameter(client, 'DB_DATABASE', _path),
20
        'host': get_database_parameter(client, 'DB_HOST', _path),
21
        'password': get_database_parameter(client, 'DB_PASSWORD', _path),
22
        'port': get_database_parameter(client, 'DB_PORT', _path),
23
        'user': get_database_parameter(client, 'DB_USERNAME', _path),
24
    }
25
26
27
def get_database_parameter(client, name, file):
28
    """
29
    Parsing a single database variable from the .env file
30
    https://gist.github.com/judy2k/7656bfe3b322d669ef75364a46327836
31
    :param client: String
32
    :param name: String
33
    :param file: String
34
    :return:
35
    """
36
    return mode.run_command(
37
        helper.get_command(client, 'grep') + f' {name} {file} | cut -d \'=\' -f2',
38
        client,
39
        True
40
    ).replace('\n', '')
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...