Loading setup.py +58 −1 Changes for setup.py: 58 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -58,11 +58,15 @@ class SetupAssets(Command): ('prepare', None, 'Prepare assets after setup'), ] # Git alias configuration # Git alias configuration, pylint: disable=too-many-locals @staticmethod def git_configuration_alias(keep: bool = False) -> None: # Variables comment: str command: str function_list: List[str] function_line: str section_current: str section_last: str = '' Loading Loading @@ -97,6 +101,8 @@ class SetupAssets(Command): # Iterate through profiles files for root, _, _ in sorted(walk(SetupAssets.PROFILES)): # Handle profile aliases for alias_file in sorted(glob(join(root, '*.alias'))): # Parse profile section Loading Loading @@ -131,6 +137,57 @@ class SetupAssets(Command): ] ]) # Handle profile functions for function_file in sorted(glob(join(root, '*.function'))): # Parse profile section section_current = root.split(sep)[-1] if section_last != section_current: section_last = section_current asset.writelines([ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '', '\t#####', f'\t## {PROJECT_NAME}: {root}', '\t###', ] ]) # Parse profile file function_name = splitext(basename(function_file))[0] with open(function_file, encoding='utf8', mode='r') as profile_file: lines = profile_file.readlines() if len(lines) >= 2: comment = lines[0].strip().lstrip('# ') function_list = lines[1:] # Prepare function syntax function_list = [ line.replace('\\"', '\\\\"').replace('"', '\\"') for line in function_list ] function_line = '' if len(function_list) == 1: function_line = f'{function_list[0].rstrip()} #' else: function_line = '\\' for line in function_list: if not function_line.endswith('\\'): function_line += ' \\' function_line += f'\n\t {line.rstrip()}' function_line += ' \\\n\t#' # Inject function configuration asset.writelines([ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '\t#', f'\t# {comment}', f'\t{function_name} = "! {function_line}"', ] ]) # Assets initialization def initialize_options(self) -> None: self.clean = None Loading Loading
setup.py +58 −1 Changes for setup.py: 58 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -58,11 +58,15 @@ class SetupAssets(Command): ('prepare', None, 'Prepare assets after setup'), ] # Git alias configuration # Git alias configuration, pylint: disable=too-many-locals @staticmethod def git_configuration_alias(keep: bool = False) -> None: # Variables comment: str command: str function_list: List[str] function_line: str section_current: str section_last: str = '' Loading Loading @@ -97,6 +101,8 @@ class SetupAssets(Command): # Iterate through profiles files for root, _, _ in sorted(walk(SetupAssets.PROFILES)): # Handle profile aliases for alias_file in sorted(glob(join(root, '*.alias'))): # Parse profile section Loading Loading @@ -131,6 +137,57 @@ class SetupAssets(Command): ] ]) # Handle profile functions for function_file in sorted(glob(join(root, '*.function'))): # Parse profile section section_current = root.split(sep)[-1] if section_last != section_current: section_last = section_current asset.writelines([ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '', '\t#####', f'\t## {PROJECT_NAME}: {root}', '\t###', ] ]) # Parse profile file function_name = splitext(basename(function_file))[0] with open(function_file, encoding='utf8', mode='r') as profile_file: lines = profile_file.readlines() if len(lines) >= 2: comment = lines[0].strip().lstrip('# ') function_list = lines[1:] # Prepare function syntax function_list = [ line.replace('\\"', '\\\\"').replace('"', '\\"') for line in function_list ] function_line = '' if len(function_list) == 1: function_line = f'{function_list[0].rstrip()} #' else: function_line = '\\' for line in function_list: if not function_line.endswith('\\'): function_line += ' \\' function_line += f'\n\t {line.rstrip()}' function_line += ' \\\n\t#' # Inject function configuration asset.writelines([ f'{line}{SetupAssets.GIT_CONFIGURATION_SEPARATOR}' for line in [ '\t#', f'\t# {comment}', f'\t{function_name} = "! {function_line}"', ] ]) # Assets initialization def initialize_options(self) -> None: self.clean = None Loading