Skip to content

Commit

Permalink
Fix build issues
Browse files Browse the repository at this point in the history
+ Fixed a couple of build issues that were making the build fail.
+ Added __main__.py to start the program when used on the command line.
  • Loading branch information
smordarski committed Jun 14, 2024
1 parent cbd2d6d commit 103f3d4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 27 deletions.
8 changes: 8 additions & 0 deletions src/site2filter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Mordarski Networks

"""site2filter is a Python program that turns a list of websites into a filter for uBlock Origin."""
from site2filter import parse_arguments


def run_site2filter():
"""Run site2filter."""
parse_arguments.main()
7 changes: 7 additions & 0 deletions src/site2filter/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Mordarski Networks

"""site2filter is a Python program that turns a list of websites into a filter for uBlock Origin."""
import site2filter

site2filter.run_site2filter()
21 changes: 21 additions & 0 deletions src/site2filter/copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Mordarski Networks

"""This module allows you to copy a given argument to the clipboard."""
import platform
import subprocess


def copy(string):
"""Copy a given argument to the clipboard.
The argument should be a string.
"""
os_dictionary = {"Windows": "clip", "Linux": "xclip -sel clip", "Darwin": "pbcopy"}

for keys, vaules in os_dictionary.items():
if platform.system() == keys:
subprocess.run(vaules, check=False, Shell=False, input=string.encode())
return True

return False
12 changes: 12 additions & 0 deletions src/site2filter/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Mordarski Networks

"""This module allows you to generate a filter."""


def read_filter():
"""Read a filter from a file."""


def generate_filter():
"""Generate a filter."""
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

"""site2filter is a Python program that turns a list of websites into a filter for uBlock Origin."""
import argparse
import platform
import subprocess


def main():
Expand All @@ -13,7 +11,6 @@ def main():
prog="site2filter",
description=__doc__,
)
args = parser.parse_args()
parser.add_argument("-f", "--filter", nargs=1, help="Choose a filter.")
parser.add_argument("-l", "--list", help="List all available filters.")
parser.add_argument(
Expand All @@ -22,34 +19,11 @@ def main():
nargs=1,
help="Give a list of websites or words seperated by a space to be blocked.",
)
args = parser.parse_args()

if args.filter:
pass
if args.list:
pass
if args.word:
pass


def read_filter():
"""Read a filter from a file."""


def generate_filter():
"""Generate a filter."""


def copy(string):
"""Copy a given argument to the clipboard.
The argument should be a string.
"""
os_dictionary = {"Windows": "clip", "Linux": "xclip -sel clip", "Darwin": "pbcopy"}

for keys, vaules in os_dictionary.items():
if platform.system() == keys:
subprocess.run(vaules, check=False, Shell=False, input=string.encode())


if __name__ == "__main__":
main()

0 comments on commit 103f3d4

Please sign in to comment.