️ szsolutions changes

This commit is contained in:
2023-10-27 17:20:46 -03:00
parent c2dd6c77e1
commit b371a410a9
5 changed files with 4 additions and 770 deletions

View File

@@ -31,24 +31,6 @@ class RepoMigrator(object):
_logger.info('Starting migration of repository %s', self._name)
self._migrated_modules = self._migrate_modules()
bug_path = oj(self.dst_path, '.gitlab', 'issue_templates')
bug_file_path = oj(bug_path, 'Bug.md')
os.makedirs(bug_path, exist_ok=True)
shutil.copy(oj(os.path.dirname(__file__), 'templates', 'Bug.md'), bug_file_path)
# Generate README.md based on modules
template_file = 'README.md'
template = self._template_env.get_template(template_file)
name = self._name
description = ''
content = template.render(
project_title=name,
project_intro=description,
modules=self._migrated_modules
)
out = open(oj(self.dst_path, 'README.md'), 'w')
out.write(content)
out.close()
# copy requirements.txt if exists
self._has_requirements = False
@@ -58,17 +40,6 @@ class RepoMigrator(object):
return self._migrated_modules
def generate_gitlab_ci(self):
template_file = 'gitlab-ci.yml'
template = self._template_env.get_template(template_file)
content = template.render(
modules=self._migrated_modules,
repository=self._name,
pip=self._has_requirements)
out = open(oj(self.dst_path, '.gitlab-ci.yml'), 'w')
out.write(content)
out.close()
def _migrate_modules(self):
migrated_modules = {}
@@ -80,7 +51,7 @@ class RepoMigrator(object):
dst_path = os.path.join(os.path.abspath(self.dst_path), file_name)
if os.path.exists(dst_path):
shutil.rmtree(dst_path)
module = ModuleMigrator(src_path, dst_path, '1.0', self._company, self._contributor).migrate()
module = ModuleMigrator(src_path, dst_path, '2.0', self._company, self._contributor).migrate()
migrated_modules = {**migrated_modules, **module}
return migrated_modules
@@ -222,33 +193,6 @@ class ModuleMigrator(object):
return {self._module_name: self._manifest}
def _render_templates(self):
# COPYRIGHT file
cr_file = oj(self._destination, 'COPYRIGHT')
if os.path.exists(cr_file):
os.remove(cr_file)
shutil.copy(oj(os.path.dirname(__file__), 'templates', 'COPYRIGHT'), self._destination)
for cr in self._copyright_list:
if not re.match('(copyright[ ]*[0-9-]+)', cr, re.IGNORECASE):
self._copyright_list.remove(cr)
copyright_list = list(set(self._copyright_list))
copyright_list = sorted(copyright_list)
existing_copyright = '\n '.join(copyright_list)
infile = self._open_read(self._destination, 'COPYRIGHT')
out = self._open_write(self._destination, 'COPYRIGHT')
infile = infile.replace('{% existing %}', existing_copyright)
out.write(infile)
out.close()
# LICENSE file
license_exists = False
if os.path.exists(oj(self._destination, 'LICENSE')):
if os.path.isdir(oj(self._destination, 'LICENSE')):
shutil.rmtree(oj(self._destination, 'LICENSE'))
else:
os.remove(oj(self._destination, 'LICENSE'))
shutil.copy(oj(os.path.dirname(__file__), 'templates', 'LICENSE'), self._destination)
# Module icon
desc_path = oj(self._destination, 'static', 'description')
os.makedirs(desc_path, exist_ok=True)
@@ -333,7 +277,7 @@ class ModuleMigrator(object):
version_parts[1] = self._release[1]
manifest['version'] = '.'.join(version_parts)
manifest['website'] = 'https://gitlab.com/flectra-community/%s' % self._repo_name
manifest['website'] = 'https://gitea.szsolutions.ch/flectra/%s' % self._repo_name
self._manifest = manifest
m = re.search('''["']version["']:[ '"]*([0-9a-zA-Z.]+)["']''', infile)
if m and m.group(1):