Compare commits

..

No commits in common. "82b4d8de7c8835f5c97d80e7cf5867550405f758" and "f0f49cce183040312d5c6b7c558fc100f21d27c6" have entirely different histories.

10 changed files with 13 additions and 85 deletions

View file

@ -1,5 +0,0 @@
#!/usr/bin/python
for i in range(0, 10000):
print(f"\033[{(i % 7) + 30}mHello World!")
print(f"\033[{(i % 7) + 90}mHello World!")

View file

@ -29,8 +29,3 @@ sshare-validate = "sshare.validator:main"
[tool.setuptools_scm]
version_file = "src/sshare/version.py"
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib"
]

View file

@ -12,8 +12,6 @@
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see <https://www.gnu.org/licenses/>.
import argparse
class NoDefault: pass
def Flag(name=None, help=None):
@ -35,8 +33,6 @@ class Argument:
self._short = None
self._long = name
self._is_remainder = kwargs.get("nargs", None) == argparse.REMAINDER
if not "default" in kwargs:
kwargs["default"] = NoDefault
kwargs["default"] = _None(kwargs["default"])
@ -47,8 +43,6 @@ class Argument:
if self._long == None:
self._long = argument
self._kwargs["metavar"] = argument
if self._is_remainder:
self._long = self.dest()
def set_flags(self, short, long):
if short != None:
@ -81,13 +75,11 @@ class Argument:
def add(self, arg_parser):
flags = []
kwargs = self._kwargs
if self._is_remainder:
flags.append(self._long)
else:
if self._short != None: flags.append(f"-{self._short}")
if self._long != None: flags.append(f"--{self._long}")
kwargs["dest"] = self.dest()
kwargs = self._kwargs | {
"dest": self.dest()
}
arg_parser.add_argument(
*flags,
**kwargs

View file

@ -14,9 +14,6 @@
import importlib
import importlib.util
import sys
from pathlib import Path
from sshare.plugin.config import Flag
from sshare.plugin.config import NoDefault
@ -35,7 +32,6 @@ class PluginLoader:
in ([ "command_line" ] if command_line else []) + [
"file",
"stdin",
"wrap_command",
"current_time",
"append_type",
"ssh",
@ -53,9 +49,9 @@ class PluginLoader:
]
@staticmethod
def at(*args, logger=None, config=dict(), flags=dict()):
def at(logger=None, config=dict(), flags=dict(), *args):
return [
Plugin.external(Path(plugin), logger, config, flags)
Plugin.external(plugin, logger, config, flags)
for plugin
in args
]

View file

@ -21,7 +21,7 @@ plugin_type = "source"
activate = { "stdin" }
config = {
"suffix": "txt",
"suffix": "txt"
}
args = {
"stdin": Flag(help="Upload from stdin")

View file

@ -1,50 +0,0 @@
# This file is part of SSHare.
#
# SSHare is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# SSHare is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see <https://www.gnu.org/licenses/>.
import argparse
import locale
import subprocess
from sshare.plugin.config import Argument
from sshare.plugin.source import Raw
plugin_type = "source"
activate = { "command" }
config = {
"suffix": "txt",
}
args = {
"command": Argument(
nargs=argparse.REMAINDER,
help="Upload the contents of the wrapped command",
)
}
def init():
config.command = config.command[1:]
def get_source():
output = b""
with subprocess.Popen(
config.command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=0,
) as process:
for line in process.stdout:
print(line.decode(locale.getpreferredencoding()), end="")
output += line
return Raw(config.suffix, output)

View file

@ -113,7 +113,7 @@ def main():
arg_parser.add_argument(
"plugins",
nargs="*",
help="plugin(s) to be validated (Default: all external plugins)",
help="plugin(s) to be validated",
)
arguments = arg_parser.parse_args()
if arguments.dev:

4
test_out.py Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/python
for i in range(0, 5):
print("\033[91mHello World!")

View file

@ -1,4 +0,0 @@
from src.sshare.plugin.config import Argument
def test_foo():
assert True