Skip to content

Commit

Permalink
Modernize imports
Browse files Browse the repository at this point in the history
We now use relative imports and a `__main__` file, so that it can be
called with `python -m rofi_rbw` (additionally to the classical entry
point `rofi-rbw`).
  • Loading branch information
fdw committed Jun 3, 2022
1 parent 68add33 commit de15ceb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 47 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ install_requires =

[options.entry_points]
console_scripts =
rofi-rbw = rofi_rbw.rofi_rbw:main
rofi-rbw = rofi_rbw.__main__:main
9 changes: 9 additions & 0 deletions src/rofi_rbw/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .rofi_rbw import RofiRbw


def main():
RofiRbw().main()


if __name__ == '__main__':
main()
7 changes: 1 addition & 6 deletions src/rofi_rbw/clipboarder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import time
from subprocess import run

try:
from rofi_rbw.abstractionhelper import is_wayland, is_installed
from rofi_rbw.typer import Typer
except ModuleNotFoundError:
from abstractionhelper import is_wayland, is_installed
from typer import Typer
from .abstractionhelper import is_wayland, is_installed


class Clipboarder:
Expand Down
5 changes: 1 addition & 4 deletions src/rofi_rbw/credentials.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from subprocess import run
from typing import Union, Optional, List

try:
from rofi_rbw.models import Target, Targets
except ModuleNotFoundError:
from models import Target, Targets
from .models import Target, Targets


class Credentials:
Expand Down
33 changes: 7 additions & 26 deletions src/rofi_rbw/rofi_rbw.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import shlex
from subprocess import run
from typing import List, Tuple, Union

import configargparse

try:
from rofi_rbw.models import Action, Target, Targets, CANCEL, DEFAULT
from rofi_rbw.clipboarder import Clipboarder
from rofi_rbw.typer import Typer
from rofi_rbw.selector import Selector
from rofi_rbw.credentials import Credentials
from rofi_rbw.entry import Entry
from rofi_rbw.paths import *
except ModuleNotFoundError:
from models import Action, Target, Targets, CANCEL, DEFAULT
from clipboarder import Clipboarder
from typer import Typer
from selector import Selector
from credentials import Credentials
from entry import Entry
from paths import *
from .models import Action, Target, Targets, CANCEL, DEFAULT
from .clipboarder import Clipboarder
from .typer import Typer
from .selector import Selector
from .credentials import Credentials
from .entry import Entry
from .paths import *

__version__ = '1.0.0-RC1'

Expand Down Expand Up @@ -225,11 +214,3 @@ def execute_action(self, cred: Credentials) -> None:
self.clipboarder.clear_clipboard_after(self.args.clear)
elif self.args.action == Action.PRINT:
print('\n'.join([cred[target] for target in self.args.targets]))


def main():
RofiRbw().main()


if __name__ == "__main__":
main()
8 changes: 2 additions & 6 deletions src/rofi_rbw/selector.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from subprocess import run
from typing import List, Tuple, Union

try:
from rofi_rbw.abstractionhelper import is_wayland, is_installed
from rofi_rbw.models import Action, Target, Targets, CANCEL, DEFAULT
except:
from abstractionhelper import is_wayland, is_installed
from models import Action, Target, Targets, CANCEL, DEFAULT
from .abstractionhelper import is_wayland, is_installed
from .models import Action, Target, Targets, CANCEL, DEFAULT


class Selector:
Expand Down
5 changes: 1 addition & 4 deletions src/rofi_rbw/typer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from subprocess import run
import time

try:
from rofi_rbw.abstractionhelper import is_wayland, is_installed
except ModuleNotFoundError:
from abstractionhelper import is_wayland, is_installed
from .abstractionhelper import is_wayland, is_installed


class Typer:
Expand Down

0 comments on commit de15ceb

Please sign in to comment.