-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_project.py
31 lines (24 loc) · 1.06 KB
/
init_project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Author: https://github.com/shendeguize
from typing import *
import os.path as osp
import argparse
class ProjectName(object):
def __init__(self, project_name: Text):
self.project_name = None
self.cmake_prefix = None
self.header_protector_prefix = None
if not self.init(project_name):
raise ValueError(f"{project_name} is not supported, snake case project name is required!")
def init(self, project_name: Text) -> bool:
if project_name.lower() != project_name or not all(project_name.split("_")):
return False
self.project_name = project_name
self.cmake_prefix = "".join(part.title() for part in self.project_name.split("_"))
self.header_protector_prefix = self.project_name.upper()
return True
def __str__(self):
return f"project_name: {self.project_name}\n"\
f"cmake_prefix: {self.cmake_prefix}\n"\
f"header_protector_prefix: {self.header_protector_prefix}\n"
if __name__ == '__main__':
parser = argparse.ArgumentParser()