new_dir.new_dir()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
rs 9.95
c 0
b 0
f 0
cc 3
nop 0
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
from pathlib import Path
5
import sys
6
7
8
def new_dir():
9
    """Creates a new Python project directory with a source dir and a tests dir"""
10
    proj_name = sys.argv[2]
11
    proj_path = Path(proj_name)
12
    # make the project directory
13
    if not proj_path.exists():
14
        proj_path.mkdir(parents=True)
15
    # create tests and src dirs
16
    for direc in (proj_name.replace("-", "_"), "tests"):
17
        sub_dir = proj_path / direc
18
        sub_dir.mkdir()
19
        (sub_dir / "__init__.py").touch()
20
21
22
if __name__ == "__main__":
23
    new_dir()
24