diff options
| author | QuietMisdreavus <grey@quietmisdreavus.net> | 2017-09-25 12:50:27 -0500 |
|---|---|---|
| committer | QuietMisdreavus <grey@quietmisdreavus.net> | 2017-09-30 13:28:09 -0500 |
| commit | 5b59c4db673d05ee71252d0d7579f325f3b726f8 (patch) | |
| tree | d31c9ae6a6e476d25880bffaef49b98a5bf30e15 /src/etc/htmldocck.py | |
| parent | dcb4378e18571fa01e20ef63820d960f1c2cc865 (diff) | |
| download | rust-5b59c4db673d05ee71252d0d7579f325f3b726f8.tar.gz rust-5b59c4db673d05ee71252d0d7579f325f3b726f8.zip | |
let htmldocck.py check for directories
Diffstat (limited to 'src/etc/htmldocck.py')
| -rw-r--r-- | src/etc/htmldocck.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index 7e8fde20346..8a11c6f7cfc 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -99,6 +99,8 @@ There are a number of supported commands: * `@count PATH XPATH COUNT' checks for the occurrence of given XPath in the given file. The number of occurrences must match the given count. +* `@has-dir PATH` checks for the existence of the given directory. + All conditions can be negated with `!`. `@!has foo/type.NoSuch.html` checks if the given file does not exist, for example. @@ -308,6 +310,12 @@ class CachedFiles(object): self.trees[path] = tree return self.trees[path] + def get_dir(self, path): + path = self.resolve_path(path) + abspath = os.path.join(self.root, path) + if not(os.path.exists(abspath) and os.path.isdir(abspath)): + raise FailedCheck('Directory does not exist {!r}'.format(path)) + def check_string(data, pat, regexp): if not pat: @@ -407,6 +415,16 @@ def check_command(c, cache): ret = expected == found else: raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) + elif c.cmd == 'has-dir': # has-dir test + if len(c.args) == 1: # @has-dir <path> = has-dir test + try: + cache.get_dir(c.args[0]) + ret = True + except FailedCheck as err: + cerr = str(err) + ret = False + else: + raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) elif c.cmd == 'valid-html': raise InvalidCheck('Unimplemented @valid-html') |
