def makeDirectory(self, path): self.log_command('makeDirectory', path) fullpath = self._fullpath(path) root = fullpath[1:] if '/' not in root and not rmatch(r"^[a-zA-Z0-9\-]+$", root): return defer.fail(CmdNotImplementedForArgError('Directory must be domain-like. [a-zA-Z0-9\-]+')) return self.swiftfilesystem.makeDirectory(fullpath)
def makeDirectory(self, fullpath, attrs): """ Make a 'directory' (either container or object). The container must exist to create a directory object inside of it. :param str fullpath: path to the directory :param dict attrs: attributes to create the directory with """ self.log_command('makeDirectory', fullpath, attrs) root = fullpath[1:] if '/' not in root and not rmatch(r"^[a-zA-Z0-9\-]+$", root): return defer.fail(SFTPError(FX_FAILURE, 'Bucket must be domain-like. [a-zA-Z0-9\-]+')) def errback(failure): failure.trap(NotFound) raise SFTPError(FX_NO_SUCH_FILE, 'Directory Not Found') d = self.swiftfilesystem.makeDirectory(fullpath, attrs) d.addErrback(errback) return d
def lookup(fpath: str, mac: str) -> bool: vendor = mac[0:8].upper().replace(":", "-") pattern = compile(r"""^[0-9A-F]{2} # match first octett at start of string [-] # match literal - [0-9A-F]{2} # match second otctett [-] # match literal - [0-9A-F]{2} # match third octett .*$ # match until end of string""", flags=VERBOSE) with open(fpath, "rb") as fp_read: for line in fp_read: match = rmatch(pattern, line.decode('utf8')) if match: entry = match.group() entry = entry.split("\t") oui = entry[0].split()[0] name = entry[-1] if vendor == oui: print(f"{Fore.GREEN}{mac} belongs to {name}") return True print(f"{Fore.RED}Couldn't find oui {vendor}") return False
def parameterize(self, url): match = rmatch(self._regex, url) if match: return match.groupdict()