Skip to content

Commit

Permalink
ui: add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
eine committed Mar 2, 2020
1 parent 610e604 commit 3e0d581
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 56 deletions.
23 changes: 11 additions & 12 deletions vunit/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""
Functionality to represent and operate on a HDL code project
"""
from typing import Optional
from typing import Optional, Union
from pathlib import Path
import logging
from collections import OrderedDict
Expand Down Expand Up @@ -83,7 +83,7 @@ def add_builtin_library(self, logical_name):
def add_library(
self,
logical_name,
directory,
directory: Union[str, Path],
vhdl_standard: VHDLStandard = VHDL.STD_2008,
is_external=False,
):
Expand All @@ -93,19 +93,18 @@ def add_library(
"""
self._validate_new_library_name(logical_name)

dpath = Path(directory)
dstr = str(directory)

if is_external:
if not exists(directory):
raise ValueError("External library %r does not exist" % directory)
if not dpath.exists():
raise ValueError("External library %r does not exist" % dstr)

if not isdir(directory):
raise ValueError(
"External library must be a directory. Got %r" % directory
)
if not dpath.is_dir():
raise ValueError("External library must be a directory. Got %r" % dstr)

library = Library(
logical_name, directory, vhdl_standard, is_external=is_external
)
LOGGER.debug("Adding library %s with path %s", logical_name, directory)
library = Library(logical_name, dstr, vhdl_standard, is_external=is_external)
LOGGER.debug("Adding library %s with path %s", logical_name, dstr)

self._libraries[logical_name] = library
self._lower_library_names_dict[logical_name.lower()] = library.name
Expand Down
4 changes: 2 additions & 2 deletions vunit/sim_if/ghdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def _get_command(self, config, output_path, elaborate_only, ghdl_e, wave_file):
cmd += ["--no-run"]
else:
try:
os.makedirs(output_path, mode=0o777)
makedirs(output_path, mode=0o777)
except OSError:
pass
with (Path(output_path) / "args.json").open("w") as fname:
Expand Down Expand Up @@ -315,7 +315,7 @@ def simulate( # pylint: disable=too-many-locals

if self._gtkwave_fmt is not None:
data_file_name = str(Path(script_path) / ("wave.%s" % self._gtkwave_fmt))
if Path(data_file_name).exists():
if Path(data_file_name).exists():
remove(data_file_name)
else:
data_file_name = None
Expand Down
Loading

0 comments on commit 3e0d581

Please sign in to comment.