-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
170 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 2 | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "friday" | ||
assignees: | ||
- "octocat" | ||
reviewers: | ||
- "lalmei" | ||
labels: | ||
- "dependencies" | ||
- "python" | ||
open-pull-requests-limit: 5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from asunder.rope_sdk.refactor.rename.rename import rename, rename_module | ||
|
||
__all__: list[str] = ["rename_module, rename"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from asunder.rope_sdk.find.find import find_definition_in_resource | ||
|
||
__all__: list[str] = ["find_definition_in_resource"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from rope.base.project import Project as RopeProject | ||
from rope.refactor.occurrences import Finder | ||
|
||
|
||
def find_definition_in_resource( | ||
repo_project: RopeProject, name: str, resource: str | ||
): | ||
FINDER = partial(Finder, repo_project) | ||
finder = FINDER(name) | ||
return next( | ||
occ | ||
for occ in finder.find_occurrences(resource=resource) | ||
if occ.is_defined() or occ.is_written() | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# @app.command() | ||
# def move(ctx: Context, | ||
# path: Path = typer.Option(Path.cwd() / "src", | ||
# help="path to package source code"), | ||
# module: str = typer.Argument( | ||
# "", help='full module name to be renamed, e.g. "package.module"'): | ||
|
||
# """ | ||
# Move module: --source <module> --target <module> [--do False] | ||
# """ | ||
# source_resource = PROJECT.get_resource(source) | ||
# target_resource = PROJECT.get_resource(target) | ||
# mover = create_move(PROJECT, source_resource) | ||
# changes = mover.get_changes(target_resource) | ||
# execute_changes(changes, do) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import logging | ||
|
||
from rope.base.change import ChangeSet | ||
from rope.base.project import Project as RopeProject | ||
from rope.refactor.rename import Rename | ||
|
||
from asunder.rope_sdk.find import find_definition_in_resource | ||
|
||
logger = logging.getLogger("asunder") | ||
|
||
|
||
def rename_module( | ||
rope_project: RopeProject, module: str, to_name: str | ||
) -> ChangeSet: | ||
module_resource = rope_project.get_resource(module) | ||
return Rename(rope_project, module_resource).get_changes(to_name) | ||
|
||
|
||
def rename( | ||
rope_project: RopeProject, module: str, from_name: str, to_name: str | ||
) -> ChangeSet: | ||
module_resource = rope_project.get_resource(module) | ||
definition_occurrence = find_definition_in_resource( | ||
rope_project, from_name, module_resource | ||
) | ||
return Rename( | ||
rope_project, module_resource, definition_occurrence.offset | ||
).get_changes(to_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,51 @@ | ||
from logging import Logger, getLogger | ||
from typing import cast | ||
from logging import WARNING, Logger, getLogger | ||
from typing import Optional, cast | ||
|
||
from rich.console import Console | ||
from rich.logging import RichHandler | ||
|
||
|
||
def get_logger_console() -> tuple[Logger, Console]: | ||
def _set_up_logger(console: Optional[Console] = None) -> Logger: | ||
""" | ||
Log to console with a simple formatter; used by CLI | ||
Parameters | ||
---------- | ||
console : Console | ||
rich console with style and colored | ||
Returns | ||
------- | ||
logging.Logger | ||
logger with the CLI name | ||
""" | ||
if not console: | ||
console = Console() | ||
module_logger = getLogger("asunder") | ||
module_logger.addHandler(RichHandler(rich_tracebacks=True, console=console)) | ||
module_logger.setLevel(level=WARNING) | ||
|
||
return module_logger | ||
|
||
|
||
def get_logger_console( | ||
console: Optional[Console] = None, | ||
) -> tuple[Logger, Console]: | ||
|
||
if not console: | ||
console = Console() | ||
|
||
logger = getLogger("asunder") | ||
|
||
if len(logger.handlers) > 0: | ||
|
||
handler: RichHandler = cast(RichHandler, logger.handlers[0]) | ||
console = handler.console | ||
print("handler names = ", [handle.__dict__ for handle in logger.handlers]) | ||
print( | ||
"handler names = ", [handle.__dict__ for handle in logger.handlers] | ||
) | ||
else: | ||
raise AttributeError("No Handlers in logger") | ||
logger = _set_up_logger(console) | ||
logger.debug("Setting up rich log handler") | ||
|
||
return logger, console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.