refactor: Move spack.util.string to llnl.util.string
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
import llnl.util.string
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.lang import pretty_seconds
|
||||
|
||||
import spack.util.string
|
||||
|
||||
if sys.platform != "win32":
|
||||
import fcntl
|
||||
@@ -165,7 +165,7 @@ def _attempts_str(wait_time, nattempts):
|
||||
if nattempts <= 1:
|
||||
return ""
|
||||
|
||||
attempts = spack.util.string.plural(nattempts, "attempt")
|
||||
attempts = llnl.util.string.plural(nattempts, "attempt")
|
||||
return " after {} and {}".format(pretty_seconds(wait_time), attempts)
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.lang import dedupe
|
||||
from llnl.util.string import plural
|
||||
from llnl.util.symlink import symlink
|
||||
from llnl.util.tty.color import cescape, colorize
|
||||
from llnl.util.tty.log import MultiProcessFd
|
||||
@@ -81,7 +82,6 @@
|
||||
from spack.util.executable import Executable
|
||||
from spack.util.log_parse import make_log_context, parse_log_events
|
||||
from spack.util.module_cmd import load_module, module, path_from_modules
|
||||
from spack.util.string import plural
|
||||
|
||||
#
|
||||
# This can be set by the user to globally disable parallel builds.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import ruamel.yaml as yaml
|
||||
from ruamel.yaml.error import MarkedYAMLError
|
||||
|
||||
import llnl.util.string
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import join_path
|
||||
from llnl.util.lang import attr_setdefault, index_by
|
||||
@@ -33,7 +34,6 @@
|
||||
import spack.traverse as traverse
|
||||
import spack.user_environment as uenv
|
||||
import spack.util.spack_json as sjson
|
||||
import spack.util.string
|
||||
|
||||
# cmd has a submodule called "list" so preserve the python list module
|
||||
python_list = list
|
||||
@@ -523,7 +523,7 @@ def print_how_many_pkgs(specs, pkg_type=""):
|
||||
category, e.g. if pkg_type is "installed" then the message
|
||||
would be "3 installed packages"
|
||||
"""
|
||||
tty.msg("%s" % spack.util.string.plural(len(specs), pkg_type + " package"))
|
||||
tty.msg("%s" % llnl.util.string.plural(len(specs), pkg_type + " package"))
|
||||
|
||||
|
||||
def spack_is_git_repo():
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import urllib.parse
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.string import plural
|
||||
|
||||
import spack.binary_distribution as bindist
|
||||
import spack.cmd
|
||||
@@ -30,7 +31,6 @@
|
||||
from spack.error import SpecError
|
||||
from spack.spec import Spec, save_dependency_specfiles
|
||||
from spack.stage import Stage
|
||||
from spack.util.string import plural
|
||||
|
||||
description = "create, download and install binary packages"
|
||||
section = "packaging"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import tempfile
|
||||
|
||||
import llnl.util.filesystem as fs
|
||||
import llnl.util.string as string
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.tty.colify import colify
|
||||
from llnl.util.tty.color import colorize
|
||||
@@ -28,7 +29,6 @@
|
||||
import spack.schema.env
|
||||
import spack.tengine
|
||||
import spack.traverse as traverse
|
||||
import spack.util.string as string
|
||||
from spack.util.environment import EnvironmentModifications
|
||||
|
||||
description = "manage virtual environments"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import io
|
||||
import sys
|
||||
|
||||
import llnl.util.string
|
||||
import llnl.util.tty as tty
|
||||
import llnl.util.tty.colify as colify
|
||||
|
||||
@@ -24,7 +25,7 @@ def report_tags(category, tags):
|
||||
if isatty:
|
||||
num = len(tags)
|
||||
fmt = "{0} package tag".format(category)
|
||||
buffer.write("{0}:\n".format(spack.util.string.plural(num, fmt)))
|
||||
buffer.write("{0}:\n".format(llnl.util.string.plural(num, fmt)))
|
||||
|
||||
if tags:
|
||||
colify.colify(tags, output=buffer, tty=isatty, indent=4)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
working_dir,
|
||||
)
|
||||
from llnl.util.symlink import symlink
|
||||
from llnl.util.string import comma_and, quote
|
||||
|
||||
import spack.config
|
||||
import spack.error
|
||||
@@ -55,7 +56,6 @@
|
||||
import spack.version
|
||||
from spack.util.compression import decompressor_for, extension_from_path
|
||||
from spack.util.executable import CommandNotFoundError, which
|
||||
from spack.util.string import comma_and, quote
|
||||
|
||||
#: List of all fetch strategies, created by FetchStrategy metaclass.
|
||||
all_strategies = []
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
import ruamel.yaml as yaml
|
||||
|
||||
import llnl.util.string
|
||||
import llnl.util.filesystem as fs
|
||||
import llnl.util.lang as lang
|
||||
import llnl.util.tty as tty
|
||||
@@ -86,7 +87,6 @@
|
||||
import spack.util.prefix
|
||||
import spack.util.spack_json as sjson
|
||||
import spack.util.spack_yaml as syaml
|
||||
import spack.util.string
|
||||
import spack.variant as vt
|
||||
import spack.version as vn
|
||||
|
||||
@@ -5041,7 +5041,7 @@ class InvalidDependencyError(spack.error.SpecError):
|
||||
def __init__(self, pkg, deps):
|
||||
self.invalid_deps = deps
|
||||
super(InvalidDependencyError, self).__init__(
|
||||
"Package {0} does not depend on {1}".format(pkg, spack.util.string.comma_or(deps))
|
||||
"Package {0} does not depend on {1}".format(pkg, llnl.util.string.comma_or(deps))
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.util.string import plural
|
||||
from llnl.util.string import plural
|
||||
|
||||
|
||||
def test_plural():
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
# Need this because of spack.util.string
|
||||
# Keeping this because of vestigial spack.util.string
|
||||
from __future__ import absolute_import
|
||||
|
||||
import inspect
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
# Need this because of spack.util.string
|
||||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
import llnl.util.lang as lang
|
||||
import llnl.util.tty.color
|
||||
from llnl.util.string import comma_or
|
||||
|
||||
import spack.directives
|
||||
import spack.error as error
|
||||
from spack.util.string import comma_or
|
||||
|
||||
special_variant_values = [None, "none", "*"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user