[scripts/util] add 'trim()' helper
This commit is contained in:
@@ -140,7 +140,7 @@ def main():
|
||||
LOG.info("Collecting data for '%s'", args.url)
|
||||
result = generate_test_result(args)
|
||||
|
||||
LOG.info("Writing '%s' results to '%s'", args.url, path)
|
||||
LOG.info("Writing '%s' results to '%s'", args.url, util.trim(path))
|
||||
insert_test_result(args, result, lines)
|
||||
|
||||
with util.lazy(path) as fp:
|
||||
|
||||
@@ -60,7 +60,7 @@ def create_extractor_module(args):
|
||||
category = args.category
|
||||
|
||||
path = util.path("gallery_dl", "extractor", f"{category}.py")
|
||||
LOG.info("Creating '%s'", trim_path(path))
|
||||
LOG.info("Creating '%s'", util.trim(path))
|
||||
|
||||
type = args.type
|
||||
if type == "manga":
|
||||
@@ -218,7 +218,7 @@ BASE_PATTERN = r"(?:https?://)?{subdomain}{re.escape(domain)}"
|
||||
|
||||
def create_test_results_file(args):
|
||||
path = util.path("test", "results", f"{args.category}.py")
|
||||
LOG.info("Creating '%s'", trim_path(path))
|
||||
LOG.info("Creating '%s'", util.trim(path))
|
||||
|
||||
import_stmt = generate_test_result_import(args)
|
||||
with util.open(path, "x") as fp:
|
||||
@@ -311,10 +311,6 @@ def insert_into_supportedsites(args):
|
||||
###############################################################################
|
||||
# General #####################################################################
|
||||
|
||||
def trim_path(path):
|
||||
return path[len(util.ROOTDIR)+1:]
|
||||
|
||||
|
||||
def parse_args(args=None):
|
||||
parser = argparse.ArgumentParser(args)
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ def path(*segments):
|
||||
return result
|
||||
|
||||
|
||||
def trim(path):
|
||||
return path[len(ROOTDIR)+1:]
|
||||
|
||||
|
||||
def open(path, mode="r"):
|
||||
return builtins.open(path, mode, encoding="utf-8", newline="\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user