remove dead code: fs.is_writable_dir was used on file (#46166)
This commit is contained in:
parent
c47a3ee05b
commit
20565ba8ab
@ -14,7 +14,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import llnl.util.filesystem as fs
|
import llnl.util.filesystem as fs
|
||||||
import llnl.util.tty as tty
|
|
||||||
from llnl.util.symlink import readlink
|
from llnl.util.symlink import readlink
|
||||||
|
|
||||||
import spack.config
|
import spack.config
|
||||||
@ -152,20 +151,9 @@ def read_spec(self, path):
|
|||||||
def spec_file_path(self, spec):
|
def spec_file_path(self, spec):
|
||||||
"""Gets full path to spec file"""
|
"""Gets full path to spec file"""
|
||||||
_check_concrete(spec)
|
_check_concrete(spec)
|
||||||
# Attempts to convert to JSON if possible.
|
|
||||||
# Otherwise just returns the YAML.
|
|
||||||
yaml_path = os.path.join(self.metadata_path(spec), self._spec_file_name_yaml)
|
yaml_path = os.path.join(self.metadata_path(spec), self._spec_file_name_yaml)
|
||||||
json_path = os.path.join(self.metadata_path(spec), self.spec_file_name)
|
json_path = os.path.join(self.metadata_path(spec), self.spec_file_name)
|
||||||
if os.path.exists(yaml_path) and fs.can_write_to_dir(yaml_path):
|
return yaml_path if os.path.exists(yaml_path) else json_path
|
||||||
self.write_spec(spec, json_path)
|
|
||||||
try:
|
|
||||||
os.remove(yaml_path)
|
|
||||||
except OSError as err:
|
|
||||||
tty.debug("Could not remove deprecated {0}".format(yaml_path))
|
|
||||||
tty.debug(err)
|
|
||||||
elif os.path.exists(yaml_path):
|
|
||||||
return yaml_path
|
|
||||||
return json_path
|
|
||||||
|
|
||||||
def deprecated_file_path(self, deprecated_spec, deprecator_spec=None):
|
def deprecated_file_path(self, deprecated_spec, deprecator_spec=None):
|
||||||
"""Gets full path to spec file for deprecated spec
|
"""Gets full path to spec file for deprecated spec
|
||||||
@ -199,17 +187,7 @@ def deprecated_file_path(self, deprecated_spec, deprecator_spec=None):
|
|||||||
deprecated_spec.dag_hash() + "_" + self.spec_file_name,
|
deprecated_spec.dag_hash() + "_" + self.spec_file_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
if os.path.exists(yaml_path) and fs.can_write_to_dir(yaml_path):
|
return yaml_path if os.path.exists(yaml_path) else json_path
|
||||||
self.write_spec(deprecated_spec, json_path)
|
|
||||||
try:
|
|
||||||
os.remove(yaml_path)
|
|
||||||
except (IOError, OSError) as err:
|
|
||||||
tty.debug("Could not remove deprecated {0}".format(yaml_path))
|
|
||||||
tty.debug(err)
|
|
||||||
elif os.path.exists(yaml_path):
|
|
||||||
return yaml_path
|
|
||||||
|
|
||||||
return json_path
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def disable_upstream_check(self):
|
def disable_upstream_check(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user