Skip to content

Commit

Permalink
Fixed package renaming in repmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
altvod committed Oct 19, 2023
1 parent 3df0f7e commit abaea69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 3 additions & 0 deletions terrarium/dl_repmanager/dl_repmanager/package_meta_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def update_mypy_common(self, to_update: dict[str, str]) -> bool:
section[k] = v
return changes

def update_package_name(self, new_name: str) -> None:
self.toml_writer.set_text_value(section_name=self._SECTION_NAME_MAIN, key='name', value=new_name)


@attr.s
class PackageMetaIOFactory:
Expand Down
18 changes: 5 additions & 13 deletions terrarium/dl_repmanager/dl_repmanager/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
from typing import (
Callable,
Collection,
Mapping,
Optional,
Sequence,
Expand All @@ -24,6 +23,7 @@
)
from dl_repmanager.repository_env import RepoEnvironment
from dl_repmanager.repository_navigator import RepositoryNavigator
from dl_repmanager.package_meta_reader import PackageMetaIOFactory


@attr.s
Expand Down Expand Up @@ -340,18 +340,10 @@ def _rename_package_internals(self, old_package_info: PackageInfo, new_package_i
exclude_masks=edit_exclude_masks,
)

# add `-` to the regex
regex, repl = self._make_regex_and_repl_for_sub(
old_str=old_package_info.package_reg_name,
new_str=new_package_info.package_reg_name,
allow_dash=False,
)
self.fs_editor.replace_regex_in_dir(
regex=regex,
repl=repl,
path=new_pkg_dir,
exclude_masks=edit_exclude_masks,
)
# Update reg name
pkg_meta_io_factory = PackageMetaIOFactory(fs_editor=self.fs_editor)
with pkg_meta_io_factory.package_meta_writer(file_path=new_package_info.toml_path) as pkg_meta_writer:
pkg_meta_writer.update_package_name(new_name=new_package_info.package_reg_name)

def change_package_type(self, package_module_name: str, new_package_type: str) -> PackageInfo:
old_package_info = self.package_index.get_package_info_from_module_name(package_module_name)
Expand Down

0 comments on commit abaea69

Please sign in to comment.