diff --git a/cm/models/confdbquery.py b/cm/models/confdbquery.py index 61f3740304f3d2149e8b7deb271e8d4327183514..9ce7c130bf2574feeb942d483a5dd782e1d51565 100644 --- a/cm/models/confdbquery.py +++ b/cm/models/confdbquery.py @@ -25,7 +25,7 @@ import cachetools # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check from noc.sa.interfaces.base import StringParameter, IntParameter, BooleanParameter diff --git a/cm/models/errortype.py b/cm/models/errortype.py index bab6b2469e85554fec2d784938c8fe4eb394c5c2..a280f354e5c3043ff1c0bf7083f7a837e8317a5a 100644 --- a/cm/models/errortype.py +++ b/cm/models/errortype.py @@ -16,7 +16,7 @@ from mongoengine.fields import StringField, UUIDField # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path @six.python_2_unicode_compatible diff --git a/cm/parsers/Cisco/ASA/base.py b/cm/parsers/Cisco/ASA/base.py index 25a5eb9e91b9c8cb66b4a2f5b74790a0a49a441a..6520471efd7232852da1fcd84938d0b059253b5c 100644 --- a/cm/parsers/Cisco/ASA/base.py +++ b/cm/parsers/Cisco/ASA/base.py @@ -10,13 +10,13 @@ import re # Third-party modules -from pyparsing import * +from pyparsing import LineStart, Literal, Word, alphanums, Optional, restOfLine, ZeroOrMore, nums # NOC modules from noc.core.ip import IPv4 from noc.cm.parsers.pyparser import BasePyParser from noc.cm.parsers.tokens import INDENT, IPv4_ADDRESS, LINE, REST, DIGITS, ALPHANUMS -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.lib.validators import is_ipv4, is_int diff --git a/cm/parsers/Cisco/IOS/base.py b/cm/parsers/Cisco/IOS/base.py index 0041fd61a32a5470f708dd4b38b37997a0a9ed71..ee99f70015c2c8332a56463f705c6ffa1abaa8e7 100644 --- a/cm/parsers/Cisco/IOS/base.py +++ b/cm/parsers/Cisco/IOS/base.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Basic IOS parser # --------------------------------------------------------------------- -# Copyright (C) 2007-2015 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -10,13 +10,23 @@ import re # Third-party modules -from pyparsing import * +from pyparsing import ( + LineStart, + Literal, + Word, + alphanums, + Optional, + restOfLine, + Combine, + ZeroOrMore, + nums, +) # NOC modules from noc.core.ip import IPv4 from noc.cm.parsers.pyparser import BasePyParser from noc.cm.parsers.tokens import INDENT, IPv4_ADDRESS, LINE, REST, DIGITS, ALPHANUMS, RD -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.lib.validators import is_ipv4, is_int diff --git a/cm/parsers/Huawei/VRP/base.py b/cm/parsers/Huawei/VRP/base.py index b8dc16d7a852eaa7d17ff5c8b161e4e2b6e46efa..096886948e2c5d53df5689dca3dd8b812ef87793 100644 --- a/cm/parsers/Huawei/VRP/base.py +++ b/cm/parsers/Huawei/VRP/base.py @@ -10,7 +10,7 @@ from collections import defaultdict # NOC modules -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.cm.parsers.base import BaseParser from noc.core.ip import IPv4 from noc.lib.validators import is_ipv4 diff --git a/cm/parsers/Qtech/QSW2800/base.py b/cm/parsers/Qtech/QSW2800/base.py index 093c4b10406266111f7cd3093353b1ff6d401dbb..b6798dd4f14b55748c59a2e5b3e93f5276f07616 100644 --- a/cm/parsers/Qtech/QSW2800/base.py +++ b/cm/parsers/Qtech/QSW2800/base.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Basic Junos parser # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ from pyparsing import OneOrMore, Word, alphanums, QuotedString # NOC modules from noc.core.ip import IPv4 from noc.cm.parsers.base import BaseParser -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list class BaseQSW2800Parser(BaseParser): diff --git a/commands/dnszone.py b/commands/dnszone.py index 7c692b9b546106b944ef5039667dc6dbe6f3639b..35e363246d8b6d73b530feb0610ead240466fe87 100644 --- a/commands/dnszone.py +++ b/commands/dnszone.py @@ -25,7 +25,7 @@ from noc.ip.models.addressprofile import AddressProfile from noc.ip.models.address import Address from noc.lib.validators import is_int from noc.dns.utils.rr import RR -from noc.lib.text import split_alnum +from noc.core.text import split_alnum class Command(BaseCommand): diff --git a/commands/interface-profile.py b/commands/interface-profile.py index 2abae050497573806f5d63fc61808470b5972652..647c193d2695bd5a9349238cbedfb105eb2f9abb 100644 --- a/commands/interface-profile.py +++ b/commands/interface-profile.py @@ -16,7 +16,7 @@ from noc.inv.models.interface import Interface from noc.inv.models.interfaceprofile import InterfaceProfile from noc.inv.models.interfaceclassificationrule import InterfaceClassificationRule from noc.sa.models.managedobjectselector import ManagedObjectSelector -from noc.lib.text import split_alnum +from noc.core.text import split_alnum class Command(BaseCommand): diff --git a/commands/nri.py b/commands/nri.py index 8138f58b210bf81948486d79aabab5fe13f451fb..1dff695c95616b976735d0265f044c86896136b2 100755 --- a/commands/nri.py +++ b/commands/nri.py @@ -16,7 +16,7 @@ from noc.core.mongo.connection import connect from noc.inv.models.interface import Interface from noc.sa.models.managedobjectselector import ManagedObjectSelector from noc.core.etl.portmapper.loader import loader -from noc.lib.text import split_alnum, format_table +from noc.core.text import split_alnum, format_table class Command(BaseCommand): diff --git a/commands/parse-events.py b/commands/parse-events.py index 986342692fdca94241420bc1d73ec7ecd26e2e01..e0ce13d24a94c3e8dd0e17d46c69d31e6c647faf 100755 --- a/commands/parse-events.py +++ b/commands/parse-events.py @@ -24,7 +24,7 @@ from noc.fm.models.mib import MIB from noc.sa.models.managedobject import ManagedObject from noc.fm.models.activeevent import ActiveEvent from noc.core.fileutils import iter_open -from noc.lib.text import format_table +from noc.core.text import format_table from noc.core.perf import metrics diff --git a/commands/service.py b/commands/service.py index 339c4e9f9fd5856f312c05b31c614eaa1289fcf6..34f5981f893539214f117dc0c1bdd1b27acb6b35 100644 --- a/commands/service.py +++ b/commands/service.py @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------- # Service command # ---------------------------------------------------------------------- -# Copyright (C) 2007-2015 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- @@ -15,7 +15,7 @@ import six # NOC modules from noc.core.management.base import BaseCommand from noc.core.service.loader import get_service -from noc.lib.text import format_table +from noc.core.text import format_table class Command(BaseCommand): diff --git a/core/etl/bi/extractor/managedobject.py b/core/etl/bi/extractor/managedobject.py index 7a2e6785e122084a2479b7a2f60218e91a01cb80..6743fb8cb1557e792971e35e1eccba6cb2037516 100644 --- a/core/etl/bi/extractor/managedobject.py +++ b/core/etl/bi/extractor/managedobject.py @@ -2,18 +2,18 @@ # ---------------------------------------------------------------------- # Managed Object Extractor # ---------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- # Python modules from __future__ import absolute_import import datetime -from noc.lib.text import ch_escape from collections import defaultdict # NOC modules from .base import BaseExtractor +from noc.core.text import ch_escape from noc.sa.models.managedobject import ManagedObject, ManagedObjectAttribute from noc.bi.models.managedobjects import ManagedObject as ManagedObjectBI from noc.core.etl.bi.stream import Stream diff --git a/core/matcher.py b/core/matcher.py index 459e518a83163cd84db7389d0d14f8081e4d7e0f..a3c4aa367fd675684d067524007379b3d669c440 100644 --- a/core/matcher.py +++ b/core/matcher.py @@ -2,17 +2,19 @@ # ---------------------------------------------------------------------- # Expression matcher # ---------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- # Python modules import re from collections import Iterable + +# Third-party modules import six # NOC modules -from noc.lib.text import split_alnum +from noc.core.text import split_alnum __all__ = ["match"] diff --git a/core/prettyjson.py b/core/prettyjson.py index e3ac59cda41b89154dd9cc7e6885f74a4f8ff0c8..984f0bc94976927b73c8415ee616aa3f782f3e57 100644 --- a/core/prettyjson.py +++ b/core/prettyjson.py @@ -15,7 +15,7 @@ import six # NOC modules from noc.core.escape import json_escape -from noc.lib.text import indent +from noc.core.text import indent class PrettyJSON(object): diff --git a/core/script/cli/base.py b/core/script/cli/base.py index ea3725e656e00a940bf49a6928e1ba402d39608e..68e771aea866d7991627d01c61f2ea464b3a5a53 100644 --- a/core/script/cli/base.py +++ b/core/script/cli/base.py @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------- # CLI FSM # ---------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- @@ -24,7 +24,7 @@ import six # NOC modules from noc.core.log import PrefixLoggerAdapter -from noc.lib.text import replace_re_group +from noc.core.text import replace_re_group from .error import ( CLIError, CLIAuthFailed, diff --git a/core/span.py b/core/span.py index df39b4595339a0a3654600745179d4bd3c59287d..6006a39011c3966ebec64c1ac96c7bde19b257c3 100644 --- a/core/span.py +++ b/core/span.py @@ -22,7 +22,7 @@ import tornado.gen from noc.core.error import NO_ERROR, ERR_UNKNOWN from noc.core.perf import metrics from noc.config import config -from noc.lib.text import ch_escape +from noc.core.text import ch_escape from noc.core.backport.time import perf_counter forensic_logger = logging.getLogger("noc.core.forensic") diff --git a/core/text.py b/core/text.py new file mode 100644 index 0000000000000000000000000000000000000000..a28ca80b20aa1819e60bed3ebb9cc9188e4ec0a5 --- /dev/null +++ b/core/text.py @@ -0,0 +1,546 @@ +# -*- coding: utf-8 -*- +# --------------------------------------------------------------------- +# Various text-processing utilities +# --------------------------------------------------------------------- +# Copyright (C) 2007-2019 The NOC Project +# See LICENSE for details +# --------------------------------------------------------------------- + +# Python modules +import re + +# Third-party modules +import six +from six.moves import zip_longest +from numpy import array + +rx_header_start = re.compile(r"^\s*[-=]+[\s\+]+[-=]+") +rx_col = re.compile(r"^([\s\+]*)([\-]+|[=]+)") + + +def parse_table( + s, + allow_wrap=False, + allow_extend=False, + expand_columns=False, + max_width=0, + footer=None, + n_row_delim="", + expand_tabs=True, +): + """ + Parse string containing table an return a list of table rows. + Each row is a list of cells. + Columns are determined by a sequences of ---- or ==== which are + determines rows bounds. + Examples: + First Second Third + ----- ------ ----- + a b c + ddd eee fff + Will be parsed down to the [["a","b","c"],["ddd","eee","fff"]] + + :param s: Table for parsing + :type s: str + :param allow_wrap: Union if cell contins multiple line + :type allow_wrap: bool + :param allow_extend: Check if column on row longest then column width, enlarge it and shift rest of columns + :type allow_extend: bool + :param expand_columns: Expand columns covering all available width + :type expand_columns: bool + :param max_width: Max table width, if table width < max_width extend length, else - nothing + :type max_width: int + :param footer: stop iteration if match expression footer + :type footer: string + :param n_row_delim: Append delimiter to next cell line + :type n_row_delim: string + :param expand_tabs: Apply expandtabs() to each line + :type expand_tabs: bool + """ + r = [] + columns = [] + if footer is not None: + rx_footer = re.compile(footer) + for line in s.splitlines(): + if expand_tabs: + # Replace tabs with spaces with step 8 + line = line.expandtabs() + if not line.strip() and footer is None: + columns = [] + continue + if footer is not None and rx_footer.search(line): + break # Footer reached, stop + if not columns and rx_header_start.match(line): + # Column delimiters found. try to determine column's width + columns = [] + x = 0 + while line: + match = rx_col.match(line) + if not match: + break + spaces = len(match.group(1)) + dashes = len(match.group(2)) + columns += [(x + spaces, x + spaces + dashes)] + x += match.end() + line = line[match.end() :] + if max_width and columns[-1][-1] < max_width: + columns[-1] = (columns[-1][0], max_width) + if expand_columns: + columns = [(cc[0], nc[0] - 1) for cc, nc in zip(columns, columns[1:])] + [ + columns[-1] + ] + elif columns: # Fetch cells + if allow_extend: + # Find which spaces between column not empty + ll = len(line) + for i, (f, t) in enumerate(columns): + if t < ll and line[t].strip(): + # If spaces not empty - shift column width equal size row + shift = len(line[f:].split()[0]) - (t - f) + # Enlarge column + columns[i] = (f, t + shift) + # Shift rest + columns[i + 1 :] = [(v[0] + shift, v[1] + shift) for v in columns[i + 1 :]] + break + if allow_wrap: + row = [line[f:t] for f, t in columns] + if r and not row[0].strip(): + # first column is empty + for i, x in enumerate(row): + if ( + x.strip() + and not r[-1][i].endswith(n_row_delim) + and not x.startswith(n_row_delim) + ): + r[-1][i] += "%s%s" % (n_row_delim, x) + else: + r[-1][i] += x + else: + r += [row] + else: + r += [[line[f:t].strip() for f, t in columns]] + if allow_wrap: + return [[x.strip() for x in rr] for rr in r] + else: + return r + + +# +# Convert HTML to plain text +# +rx_html_tags = re.compile("+]+>", re.MULTILINE | re.DOTALL) + + +def strip_html_tags(s): + t = rx_html_tags.sub("", s) + for k, v in [(" ", " "), ("<", "<"), (">", ">"), ("&", "&")]: + t = t.replace(k, v) + return t + + +# +# Convert XML to list of elements +# +def xml_to_table(s, root, row): + # pylint: disable=line-too-long + """ + >>> xml_to_table('1234','action','row') # noqa + [{'a': '1', 'b': '2'}, {'a': '3', 'b': '4'}] + """ + # Detect root element + match = re.search(r"<%s>(.*)" % (root, root), s, re.DOTALL | re.IGNORECASE) + if not match: + return [] + s = match.group(1) + row_re = re.compile(r"<%s>(.*?)" % (row, row), re.DOTALL | re.IGNORECASE) + item_re = re.compile(r"<([^\]+])>(.*?)", re.DOTALL | re.IGNORECASE) + r = [] + for m in [x for x in row_re.split(s) if x]: + data = item_re.findall(m) + if data: + r += [dict(data)] + return r + + +# +# Convert list of values to string of ranges +# +def list_to_ranges(s): + """ + >>> list_to_ranges([]) + '' + >>> list_to_ranges([1]) + '1' + >>> list_to_ranges([1,2]) + '1-2' + >>> list_to_ranges([1,2,3]) + '1-3' + >>> list_to_ranges([1,2,3,5]) + '1-3,5' + >>> list_to_ranges([1,2,3,5,6,7]) + '1-3,5-7' + >>> list_to_ranges(range(1,4001)) + '1-4000' + """ + + def f(): + if last_start == last_end: + return str(last_start) + else: + return "%d-%d" % (last_start, last_end) + + last_start = None + last_end = None + r = [] + for i in sorted(s): + if last_end is not None and i == last_end + 1: + last_end += 1 + else: + if last_start is not None: + r += [f()] + last_start = i + last_end = i + if last_start is not None: + r += [f()] + return ",".join(r) + + +# +# Convert range string to a list of integers +# +rx_range = re.compile(r"^(\d+)\s*-\s*(\d+)$") + + +def ranges_to_list(s, splitter=","): + """ + >>> ranges_to_list("1") + [1] + >>> ranges_to_list("1, 2") + [1, 2] + >>> ranges_to_list("1, 10-12") + [1, 10, 11, 12] + >>> ranges_to_list("1, 10-12, 15, 17-19") + [1, 10, 11, 12, 15, 17, 18, 19] + """ + r = [] + if "to" in s: + s = s.replace(" to ", "-") + for p in s.split(splitter): + p = p.strip() + try: + r += [int(p)] + continue + except ValueError: + pass + match = rx_range.match(p) + if not match: + raise SyntaxError + f, t = [int(x) for x in match.groups()] + if f >= t: + raise SyntaxError + for i in range(f, t + 1): + r += [i] + return sorted(r) + + +# +# Replace regular expression group with pattern +# +def replace_re_group(expr, group, pattern): + """ + >>> replace_re_group("nothing","(?P","groupvalue") + 'nothing' + >>> replace_re_group("the (?Psimple) test","(?P","groupvalue") + 'the groupvalue test' + >>> replace_re_group("the (?P nested (test)>)","(?P","groupvalue") + 'the groupvalue' + """ + r = "" + lg = len(group) + while expr: + idx = expr.find(group) + if idx == -1: + return r + expr # No more groups found + r += expr[:idx] + expr = expr[idx + lg :] + level = 1 # Level of parenthesis nesting + while expr: + c = expr[0] + expr = expr[1:] + if c == "\\": + # Skip quoted character + expr = expr[1:] + continue + elif c == "(": + # Increase nesting level + level += 1 + continue + elif c == ")": + # Decrease nesting level + level -= 1 + if level == 0: + # Replace with pattern and search for next + r += pattern + break + return r + expr + + +def indent(text, n=4): + """ + Indent each line of text with spaces + + :param text: text + :param n: amount of spaces to ident + + >>> indent("") + '' + >>> indent("the quick brown fox\\njumped over an lazy dog\\nend") + ' the quick brown fox\\n jumped over an lazy dog\\n end' + """ + if not text: + return "" + i = " " * n + return i + text.replace("\n", "\n" + i) + + +def split_alnum(s): + """ + Split line to a sequence of iterating alpha and digit strings + + :param s: + :type s: str + :return: list + :rtype: list + + >>> split_alnum("Fa 0/1") + ['Fa ', 0, '/', 1] + >>> split_alnum("Fa 0/1.15") + ['Fa ', 0, '/', 1, '.', 15] + >>> split_alnum("ge-1/0/1") + ['ge-', 1, '/', 0, '/', 1] + >>> split_alnum("ge-1/0/1.15") + ['ge-', 1, '/', 0, '/', 1, '.', 15] + """ + + def convert(x): + try: + return int(x) + except ValueError: + return x + + r = [] + digit = None + for c in s: + d = c.isdigit() + if d != digit: + digit = d + r += [c] + else: + r[-1] += c + return [convert(x) for x in r] + + +rx_notspace = re.compile(r"^\S+") + + +def find_indented(s): + """ + Parses following text structure: + + section 1 header + line 1 + line 2 + section 2 header + line 1 + line 2 + + >>> find_idented("section0\\nsection 1\\n line 1-1\\n line 1-2\\n\\n"\ + "section 2\\n line 2-1\\n line 2-2") + ['section 1\n line 1-1\n line 1-2', 'section 2\n line 2-1\n line 2-2'] + :param s: + :return: + """ + r = [] + cr = [] + for l in s.splitlines(): + if rx_notspace.match(l): + if len(cr) > 1: + r += ["\n".join(cr)] + cr = [l] + continue + elif l: + cr += [l] + if len(cr) > 1: + r += ["\n".join(cr)] + return r + + +def parse_kv(kmap, data, sep=":"): + """ + :param kmap: text -> dict mapping + :param data: + :return: dict + """ + r = {} + for line in data.splitlines(): + if sep not in line: + continue + k, v = line.strip().split(sep, 1) + k = k.strip().lower() + if k in kmap: + r[kmap[k]] = v.strip() + return r + + +def str_dict(d): + """ + Convert dict to key=value, key=value, .... string + :type d: dict + :rtype: str + """ + return ", ".join("%s=%s" % (k, d[k]) for k in d) + + +rx_safe_path = re.compile(r"[^a-z0-9\-\+]+", re.IGNORECASE) + + +def quote_safe_path(d): + return rx_safe_path.sub("_", d) + + +def to_seconds(v): + """ + Convert string value to seconds. + Available acronyms are h, d, w, m, y + """ + m = 1 + if v.endswith("h"): + v = v[:-1] + m = 3600 + elif v.endswith("d"): + v = v[:-1] + m = 24 * 3600 + elif v.endswith("w"): + v = v[:-1] + m = 7 * 24 * 3600 + elif v.endswith("m"): + v = v[:-1] + m = 30 * 24 * 3600 + elif v.endswith("y"): + v = v[:-1] + m = 365 * 24 * 3600 + try: + v = int(v) + except ValueError: + raise "Invalid time: %s" % v + return v * m + + +def format_table(widths, data, sep=" ", hsep=" "): + """ + Print formatted table. + :param widths: list of minimal column widths + :param data: list of rows, first row is the header + :param sep: column separator + :param hsep: header line separator + """ + # Calculate column widths + widths = list(widths) + for row in data: + widths = [max(x, len(y)) for x, y in zip(widths, row)] + # Build print mask + mask = sep.join("%%-%ds" % w for w in widths) + out = [ + # Header line + mask % tuple(data[0]), + # Header separator + hsep.join("-" * w for w in widths), + ] + out += [mask % tuple(row) for row in data[1:]] + return "\n".join(out) + + +rx_non_numbers = re.compile("[^0-9]+") + + +def clean_number(n): + """ + Remove all non-number occurences + :param n: + :return: + """ + return rx_non_numbers.sub("", n) + + +def safe_shadow(text): + """ + Shadow string to first and last char + :param text: + :return: + + >>> safe_shadow(None) + 'None' + >>>safe_shadow("s") + '******' + >>>safe_shadow("sssssss") + 's******s' + >>> safe_shadow(1) + '******' + >>> safe_shadow([1, 2]) + '******' + """ + if not text: + return "None" + elif not isinstance(text, six.string_types): + return "******" + elif len(text) > 2: + return "%s******%s" % (text[0], text[-1]) + else: + return "******" + + +def ch_escape(s): + return s.replace("\n", "\\n").replace("\t", "\\t").replace("\\", "\\\\") + + +ESC_REPLACEMENTS = {re.escape("\n"): " ", re.escape("\t"): " "} + +rx_escape = re.compile("|".join(ESC_REPLACEMENTS)) + + +def tsv_escape(text): + return rx_escape.sub(lambda match: ESC_REPLACEMENTS[re.escape(match.group(0))], text) + + +def parse_table_header(v): + """ + Parse header structured multiline format: + Config Current Agg Min Ld Share Flags Ld Share Agg Link Link Up + Master Master Control Active Algorithm Group Mbr State Transitions + :param v: + :return: Dictionary {start column position: header} + {10: 'Config Master', 18: 'Current Master', 26: 'Agg Control', 33: 'Min Active', + 43: 'Ld Share Algorithm', 49: 'Flags ', 59: 'Ld Share Group', 63: 'Agg Mbr', 69: 'Link State'} + """ + head = [] + empty_header = None + header = {} + for num, lines in enumerate(zip_longest(*v, fillvalue="-")): + # + if empty_header is None: + empty_header = (" ",) * len(lines) + head += [lines] + continue + if set(head[-1]) == {" "} and lines != empty_header: + head = array(head) + # Transpone list header string + header[num] = " ".join(["".join(s).strip() for s in head.transpose().tolist()]) + header[num] = header[num].strip() + head = [] + head += [lines] + else: + # last column + head = array(head) + header[num] = " ".join(["".join(s).strip(" -") for s in head.transpose().tolist()]) + header[num] = header[num].strip() + return header diff --git a/core/topology/base.py b/core/topology/base.py index c19ef4f43768ba69768588d1101b3b7a58a4fc38..88eae4763170f654c0152ce64a9a2a22537cbc28 100644 --- a/core/topology/base.py +++ b/core/topology/base.py @@ -17,7 +17,7 @@ import cachetools # NOC modules from noc.core.stencil import stencil_registry -from noc.lib.text import split_alnum +from noc.core.text import split_alnum from .layout.ring import RingLayout from .layout.spring import SpringLayout from .layout.tree import TreeLayout diff --git a/dev/models/quiz.py b/dev/models/quiz.py index b5e382db86905b5394caea242c1d616476791641..4e50d92b07a8922204d4b8f54d925ac69f4b811f 100644 --- a/dev/models/quiz.py +++ b/dev/models/quiz.py @@ -25,7 +25,7 @@ import cachetools # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check id_lock = Lock() diff --git a/dev/models/spec.py b/dev/models/spec.py index c191aa49c06f65dc513e3cfaf1535edc0d5766f6..bd044d6dfc50d8fbe94b25f28f021ae721440929 100644 --- a/dev/models/spec.py +++ b/dev/models/spec.py @@ -27,7 +27,7 @@ import cachetools # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.mongo.fields import PlainReferenceField from noc.sa.models.profile import Profile from .quiz import Quiz, Q_TYPES diff --git a/fm/models/alarmclass.py b/fm/models/alarmclass.py index 4c8d467242412daaa95ecaa668f3a5f56dd4a25e..afac4cc8b89d0594d22c43fd76c0459a136f5366 100644 --- a/fm/models/alarmclass.py +++ b/fm/models/alarmclass.py @@ -32,7 +32,7 @@ import cachetools # NOC modules from noc.core.mongo.fields import PlainReferenceField from noc.core.escape import json_escape as q -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.handler import get_handler from noc.core.bi.decorator import bi_sync from noc.core.model.decorator import on_delete_check diff --git a/fm/models/alarmseverity.py b/fm/models/alarmseverity.py index d6bd20c838e6139f0f29cec3b9830cda3a7ffb44..92aaab50148bf96050da6665646b295040b08a3e 100644 --- a/fm/models/alarmseverity.py +++ b/fm/models/alarmseverity.py @@ -20,7 +20,7 @@ import cachetools # NOC modules from noc.main.models.style import Style from noc.core.mongo.fields import ForeignKeyField -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from core.prettyjson import to_json from noc.core.model.decorator import on_delete_check diff --git a/fm/models/cloneclassificationrule.py b/fm/models/cloneclassificationrule.py index dc773e7ede9dc6ddb80236015b0ff5a68cf0d6f4..6c604bdb034effa6ca583fb2a89360c2db6c359a 100644 --- a/fm/models/cloneclassificationrule.py +++ b/fm/models/cloneclassificationrule.py @@ -15,7 +15,7 @@ from mongoengine.document import Document from mongoengine import fields # NOC modules -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.prettyjson import to_json diff --git a/fm/models/enumeration.py b/fm/models/enumeration.py index 7fe93c2854440b3ceaf284c4472e3b59fdfa512a..e7036906df34fd1d0561fe6c01951d0be780e191 100644 --- a/fm/models/enumeration.py +++ b/fm/models/enumeration.py @@ -12,7 +12,7 @@ from mongoengine.document import Document from mongoengine.fields import StringField, DictField, UUIDField # Python modules -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.prettyjson import to_json diff --git a/fm/models/eventclass.py b/fm/models/eventclass.py index 0aa733600f3ab0d52403aa307502c8dcfd1c8c1d..593f7c5d168814285092795701db17ca2682cf3c 100644 --- a/fm/models/eventclass.py +++ b/fm/models/eventclass.py @@ -31,7 +31,7 @@ import cachetools # NOC modules from noc.core.mongo.fields import PlainReferenceField from noc.core.escape import json_escape as q -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.handler import get_handler from noc.core.model.decorator import on_delete_check from .alarmclass import AlarmClass diff --git a/fm/models/eventclassificationrule.py b/fm/models/eventclassificationrule.py index 39f8f4f55348417f6ddabaa9e3ce1f7b6727d0ea..cba35b1a0a0f8dac5e3f747841af5d359686fd79 100644 --- a/fm/models/eventclassificationrule.py +++ b/fm/models/eventclassificationrule.py @@ -20,7 +20,7 @@ from .eventclass import EventClass from .datasource import DataSource from noc.core.mongo.fields import PlainReferenceField from noc.core.escape import json_escape as jq -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path @six.python_2_unicode_compatible diff --git a/gis/models/layer.py b/gis/models/layer.py index 9a9a3f91d21c4401fc46e1f73dbe21e26f12ba12..89fc44e6a4e78a248b8cee94a574bb1b740951b7 100644 --- a/gis/models/layer.py +++ b/gis/models/layer.py @@ -19,7 +19,7 @@ import cachetools # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check id_lock = Lock() diff --git a/inv/models/capability.py b/inv/models/capability.py index 71563e7188a0b222e0a178ced872d52d51276dd1..bbdbe63afae9be538d159192d9d2ec7fa7b908e0 100644 --- a/inv/models/capability.py +++ b/inv/models/capability.py @@ -20,7 +20,7 @@ import cachetools # NOC modules from noc.main.models.doccategory import category from core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check id_lock = Lock() diff --git a/inv/models/connectionrule.py b/inv/models/connectionrule.py index 98398b53181505e23beabbb6a3ef5fb1f063aff0..965e43e526800913120674efbd98bd554afc0726 100644 --- a/inv/models/connectionrule.py +++ b/inv/models/connectionrule.py @@ -16,7 +16,7 @@ from mongoengine.fields import StringField, UUIDField, ListField, EmbeddedDocume # NOC modules from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check diff --git a/inv/models/connectiontype.py b/inv/models/connectiontype.py index ef2202929563bd42682d5047efbac613aa58c2a6..7b7cf81ccf280a596c7c353426eeac4431ba47df 100644 --- a/inv/models/connectiontype.py +++ b/inv/models/connectiontype.py @@ -24,7 +24,7 @@ from mongoengine.fields import ( # NOC modules from noc.core.mongo.fields import PlainReferenceField from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.main.models.doccategory import category from noc.core.model.decorator import on_delete_check diff --git a/inv/models/firmwarepolicy.py b/inv/models/firmwarepolicy.py index f1bb8ca7848cc6e170c3e7dfce22e08dfe139398..decd6b385b9acf4cdfa2568ddc0fb77341c77275 100644 --- a/inv/models/firmwarepolicy.py +++ b/inv/models/firmwarepolicy.py @@ -18,7 +18,7 @@ from noc.sa.models.managedobjectprofile import ManagedObjectProfile from .firmware import Firmware from .platform import Platform from noc.core.mongo.fields import ForeignKeyField, PlainReferenceField -from noc.lib.text import split_alnum +from noc.core.text import split_alnum FS_RECOMMENDED = "r" diff --git a/inv/models/objectmodel.py b/inv/models/objectmodel.py index 951345c00043882982b6e41ea78757ed2976aaea..43697615a92a835eaab912d08130375e1e3f6c26 100644 --- a/inv/models/objectmodel.py +++ b/inv/models/objectmodel.py @@ -34,7 +34,7 @@ from .vendor import Vendor from noc.main.models.doccategory import category from noc.core.mongo.fields import PlainReferenceField from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.model.decorator import on_delete_check, on_save id_lock = Lock() diff --git a/inv/models/technology.py b/inv/models/technology.py index 5afedb1f461619c02c228743f4a6e72b0c77e42c..1bd69edcc32f5b6bd04fa0565b47d1ea91e6ae88 100644 --- a/inv/models/technology.py +++ b/inv/models/technology.py @@ -21,7 +21,7 @@ import cachetools from noc.core.model.decorator import on_delete_check from noc.core.bi.decorator import bi_sync from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path id_lock = threading.Lock() diff --git a/lib/text.py b/lib/text.py index a28ca80b20aa1819e60bed3ebb9cc9188e4ec0a5..774cc98c678585ea6d520b686c53a5f7a76078a0 100644 --- a/lib/text.py +++ b/lib/text.py @@ -1,546 +1,42 @@ # -*- coding: utf-8 -*- -# --------------------------------------------------------------------- -# Various text-processing utilities -# --------------------------------------------------------------------- +# ---------------------------------------------------------------------- +# noc.core.text legacy wrappers +# flake8: noqa +# ---------------------------------------------------------------------- # Copyright (C) 2007-2019 The NOC Project # See LICENSE for details -# --------------------------------------------------------------------- +# ---------------------------------------------------------------------- # Python modules -import re - -# Third-party modules -import six -from six.moves import zip_longest -from numpy import array - -rx_header_start = re.compile(r"^\s*[-=]+[\s\+]+[-=]+") -rx_col = re.compile(r"^([\s\+]*)([\-]+|[=]+)") - - -def parse_table( - s, - allow_wrap=False, - allow_extend=False, - expand_columns=False, - max_width=0, - footer=None, - n_row_delim="", - expand_tabs=True, -): - """ - Parse string containing table an return a list of table rows. - Each row is a list of cells. - Columns are determined by a sequences of ---- or ==== which are - determines rows bounds. - Examples: - First Second Third - ----- ------ ----- - a b c - ddd eee fff - Will be parsed down to the [["a","b","c"],["ddd","eee","fff"]] - - :param s: Table for parsing - :type s: str - :param allow_wrap: Union if cell contins multiple line - :type allow_wrap: bool - :param allow_extend: Check if column on row longest then column width, enlarge it and shift rest of columns - :type allow_extend: bool - :param expand_columns: Expand columns covering all available width - :type expand_columns: bool - :param max_width: Max table width, if table width < max_width extend length, else - nothing - :type max_width: int - :param footer: stop iteration if match expression footer - :type footer: string - :param n_row_delim: Append delimiter to next cell line - :type n_row_delim: string - :param expand_tabs: Apply expandtabs() to each line - :type expand_tabs: bool - """ - r = [] - columns = [] - if footer is not None: - rx_footer = re.compile(footer) - for line in s.splitlines(): - if expand_tabs: - # Replace tabs with spaces with step 8 - line = line.expandtabs() - if not line.strip() and footer is None: - columns = [] - continue - if footer is not None and rx_footer.search(line): - break # Footer reached, stop - if not columns and rx_header_start.match(line): - # Column delimiters found. try to determine column's width - columns = [] - x = 0 - while line: - match = rx_col.match(line) - if not match: - break - spaces = len(match.group(1)) - dashes = len(match.group(2)) - columns += [(x + spaces, x + spaces + dashes)] - x += match.end() - line = line[match.end() :] - if max_width and columns[-1][-1] < max_width: - columns[-1] = (columns[-1][0], max_width) - if expand_columns: - columns = [(cc[0], nc[0] - 1) for cc, nc in zip(columns, columns[1:])] + [ - columns[-1] - ] - elif columns: # Fetch cells - if allow_extend: - # Find which spaces between column not empty - ll = len(line) - for i, (f, t) in enumerate(columns): - if t < ll and line[t].strip(): - # If spaces not empty - shift column width equal size row - shift = len(line[f:].split()[0]) - (t - f) - # Enlarge column - columns[i] = (f, t + shift) - # Shift rest - columns[i + 1 :] = [(v[0] + shift, v[1] + shift) for v in columns[i + 1 :]] - break - if allow_wrap: - row = [line[f:t] for f, t in columns] - if r and not row[0].strip(): - # first column is empty - for i, x in enumerate(row): - if ( - x.strip() - and not r[-1][i].endswith(n_row_delim) - and not x.startswith(n_row_delim) - ): - r[-1][i] += "%s%s" % (n_row_delim, x) - else: - r[-1][i] += x - else: - r += [row] - else: - r += [[line[f:t].strip() for f, t in columns]] - if allow_wrap: - return [[x.strip() for x in rr] for rr in r] - else: - return r - - -# -# Convert HTML to plain text -# -rx_html_tags = re.compile("+]+>", re.MULTILINE | re.DOTALL) - - -def strip_html_tags(s): - t = rx_html_tags.sub("", s) - for k, v in [(" ", " "), ("<", "<"), (">", ">"), ("&", "&")]: - t = t.replace(k, v) - return t - - -# -# Convert XML to list of elements -# -def xml_to_table(s, root, row): - # pylint: disable=line-too-long - """ - >>> xml_to_table('1234','action','row') # noqa - [{'a': '1', 'b': '2'}, {'a': '3', 'b': '4'}] - """ - # Detect root element - match = re.search(r"<%s>(.*)" % (root, root), s, re.DOTALL | re.IGNORECASE) - if not match: - return [] - s = match.group(1) - row_re = re.compile(r"<%s>(.*?)" % (row, row), re.DOTALL | re.IGNORECASE) - item_re = re.compile(r"<([^\]+])>(.*?)", re.DOTALL | re.IGNORECASE) - r = [] - for m in [x for x in row_re.split(s) if x]: - data = item_re.findall(m) - if data: - r += [dict(data)] - return r - - -# -# Convert list of values to string of ranges -# -def list_to_ranges(s): - """ - >>> list_to_ranges([]) - '' - >>> list_to_ranges([1]) - '1' - >>> list_to_ranges([1,2]) - '1-2' - >>> list_to_ranges([1,2,3]) - '1-3' - >>> list_to_ranges([1,2,3,5]) - '1-3,5' - >>> list_to_ranges([1,2,3,5,6,7]) - '1-3,5-7' - >>> list_to_ranges(range(1,4001)) - '1-4000' - """ - - def f(): - if last_start == last_end: - return str(last_start) - else: - return "%d-%d" % (last_start, last_end) - - last_start = None - last_end = None - r = [] - for i in sorted(s): - if last_end is not None and i == last_end + 1: - last_end += 1 - else: - if last_start is not None: - r += [f()] - last_start = i - last_end = i - if last_start is not None: - r += [f()] - return ",".join(r) - - -# -# Convert range string to a list of integers -# -rx_range = re.compile(r"^(\d+)\s*-\s*(\d+)$") - - -def ranges_to_list(s, splitter=","): - """ - >>> ranges_to_list("1") - [1] - >>> ranges_to_list("1, 2") - [1, 2] - >>> ranges_to_list("1, 10-12") - [1, 10, 11, 12] - >>> ranges_to_list("1, 10-12, 15, 17-19") - [1, 10, 11, 12, 15, 17, 18, 19] - """ - r = [] - if "to" in s: - s = s.replace(" to ", "-") - for p in s.split(splitter): - p = p.strip() - try: - r += [int(p)] - continue - except ValueError: - pass - match = rx_range.match(p) - if not match: - raise SyntaxError - f, t = [int(x) for x in match.groups()] - if f >= t: - raise SyntaxError - for i in range(f, t + 1): - r += [i] - return sorted(r) - - -# -# Replace regular expression group with pattern -# -def replace_re_group(expr, group, pattern): - """ - >>> replace_re_group("nothing","(?P","groupvalue") - 'nothing' - >>> replace_re_group("the (?Psimple) test","(?P","groupvalue") - 'the groupvalue test' - >>> replace_re_group("the (?P nested (test)>)","(?P","groupvalue") - 'the groupvalue' - """ - r = "" - lg = len(group) - while expr: - idx = expr.find(group) - if idx == -1: - return r + expr # No more groups found - r += expr[:idx] - expr = expr[idx + lg :] - level = 1 # Level of parenthesis nesting - while expr: - c = expr[0] - expr = expr[1:] - if c == "\\": - # Skip quoted character - expr = expr[1:] - continue - elif c == "(": - # Increase nesting level - level += 1 - continue - elif c == ")": - # Decrease nesting level - level -= 1 - if level == 0: - # Replace with pattern and search for next - r += pattern - break - return r + expr - - -def indent(text, n=4): - """ - Indent each line of text with spaces - - :param text: text - :param n: amount of spaces to ident - - >>> indent("") - '' - >>> indent("the quick brown fox\\njumped over an lazy dog\\nend") - ' the quick brown fox\\n jumped over an lazy dog\\n end' - """ - if not text: - return "" - i = " " * n - return i + text.replace("\n", "\n" + i) - - -def split_alnum(s): - """ - Split line to a sequence of iterating alpha and digit strings - - :param s: - :type s: str - :return: list - :rtype: list - - >>> split_alnum("Fa 0/1") - ['Fa ', 0, '/', 1] - >>> split_alnum("Fa 0/1.15") - ['Fa ', 0, '/', 1, '.', 15] - >>> split_alnum("ge-1/0/1") - ['ge-', 1, '/', 0, '/', 1] - >>> split_alnum("ge-1/0/1.15") - ['ge-', 1, '/', 0, '/', 1, '.', 15] - """ - - def convert(x): - try: - return int(x) - except ValueError: - return x - - r = [] - digit = None - for c in s: - d = c.isdigit() - if d != digit: - digit = d - r += [c] - else: - r[-1] += c - return [convert(x) for x in r] - - -rx_notspace = re.compile(r"^\S+") - - -def find_indented(s): - """ - Parses following text structure: - - section 1 header - line 1 - line 2 - section 2 header - line 1 - line 2 - - >>> find_idented("section0\\nsection 1\\n line 1-1\\n line 1-2\\n\\n"\ - "section 2\\n line 2-1\\n line 2-2") - ['section 1\n line 1-1\n line 1-2', 'section 2\n line 2-1\n line 2-2'] - :param s: - :return: - """ - r = [] - cr = [] - for l in s.splitlines(): - if rx_notspace.match(l): - if len(cr) > 1: - r += ["\n".join(cr)] - cr = [l] - continue - elif l: - cr += [l] - if len(cr) > 1: - r += ["\n".join(cr)] - return r - - -def parse_kv(kmap, data, sep=":"): - """ - :param kmap: text -> dict mapping - :param data: - :return: dict - """ - r = {} - for line in data.splitlines(): - if sep not in line: - continue - k, v = line.strip().split(sep, 1) - k = k.strip().lower() - if k in kmap: - r[kmap[k]] = v.strip() - return r - - -def str_dict(d): - """ - Convert dict to key=value, key=value, .... string - :type d: dict - :rtype: str - """ - return ", ".join("%s=%s" % (k, d[k]) for k in d) - - -rx_safe_path = re.compile(r"[^a-z0-9\-\+]+", re.IGNORECASE) - - -def quote_safe_path(d): - return rx_safe_path.sub("_", d) - - -def to_seconds(v): - """ - Convert string value to seconds. - Available acronyms are h, d, w, m, y - """ - m = 1 - if v.endswith("h"): - v = v[:-1] - m = 3600 - elif v.endswith("d"): - v = v[:-1] - m = 24 * 3600 - elif v.endswith("w"): - v = v[:-1] - m = 7 * 24 * 3600 - elif v.endswith("m"): - v = v[:-1] - m = 30 * 24 * 3600 - elif v.endswith("y"): - v = v[:-1] - m = 365 * 24 * 3600 - try: - v = int(v) - except ValueError: - raise "Invalid time: %s" % v - return v * m - - -def format_table(widths, data, sep=" ", hsep=" "): - """ - Print formatted table. - :param widths: list of minimal column widths - :param data: list of rows, first row is the header - :param sep: column separator - :param hsep: header line separator - """ - # Calculate column widths - widths = list(widths) - for row in data: - widths = [max(x, len(y)) for x, y in zip(widths, row)] - # Build print mask - mask = sep.join("%%-%ds" % w for w in widths) - out = [ - # Header line - mask % tuple(data[0]), - # Header separator - hsep.join("-" * w for w in widths), - ] - out += [mask % tuple(row) for row in data[1:]] - return "\n".join(out) - - -rx_non_numbers = re.compile("[^0-9]+") - - -def clean_number(n): - """ - Remove all non-number occurences - :param n: - :return: - """ - return rx_non_numbers.sub("", n) - - -def safe_shadow(text): - """ - Shadow string to first and last char - :param text: - :return: - - >>> safe_shadow(None) - 'None' - >>>safe_shadow("s") - '******' - >>>safe_shadow("sssssss") - 's******s' - >>> safe_shadow(1) - '******' - >>> safe_shadow([1, 2]) - '******' - """ - if not text: - return "None" - elif not isinstance(text, six.string_types): - return "******" - elif len(text) > 2: - return "%s******%s" % (text[0], text[-1]) - else: - return "******" - - -def ch_escape(s): - return s.replace("\n", "\\n").replace("\t", "\\t").replace("\\", "\\\\") - - -ESC_REPLACEMENTS = {re.escape("\n"): " ", re.escape("\t"): " "} - -rx_escape = re.compile("|".join(ESC_REPLACEMENTS)) - - -def tsv_escape(text): - return rx_escape.sub(lambda match: ESC_REPLACEMENTS[re.escape(match.group(0))], text) - - -def parse_table_header(v): - """ - Parse header structured multiline format: - Config Current Agg Min Ld Share Flags Ld Share Agg Link Link Up - Master Master Control Active Algorithm Group Mbr State Transitions - :param v: - :return: Dictionary {start column position: header} - {10: 'Config Master', 18: 'Current Master', 26: 'Agg Control', 33: 'Min Active', - 43: 'Ld Share Algorithm', 49: 'Flags ', 59: 'Ld Share Group', 63: 'Agg Mbr', 69: 'Link State'} - """ - head = [] - empty_header = None - header = {} - for num, lines in enumerate(zip_longest(*v, fillvalue="-")): - # - if empty_header is None: - empty_header = (" ",) * len(lines) - head += [lines] - continue - if set(head[-1]) == {" "} and lines != empty_header: - head = array(head) - # Transpone list header string - header[num] = " ".join(["".join(s).strip() for s in head.transpose().tolist()]) - header[num] = header[num].strip() - head = [] - head += [lines] - else: - # last column - head = array(head) - header[num] = " ".join(["".join(s).strip(" -") for s in head.transpose().tolist()]) - header[num] = header[num].strip() - return header +import warnings + +# NOC modules +from noc.core.text import ( + parse_table, + strip_html_tags, + xml_to_table, + list_to_ranges, + ranges_to_list, + replace_re_group, + indent, + split_alnum, + find_indented, + parse_kv, + str_dict, + quote_safe_path, + to_seconds, + format_table, + clean_number, + safe_shadow, + ch_escape, + tsv_escape, + parse_table_header, +) +from noc.core.deprecations import RemovedInNOC1905Warning + +warnings.warn( + "noc.lib.text is deprecated and will be removed in NOC 19.5. " + "Please replace imports to noc.core.text", + RemovedInNOC1905Warning, + stacklevel=2, +) diff --git a/phone/models/phonenumber.py b/phone/models/phonenumber.py index 2f774b8ae10c7c9d0764f813c628b8e3280b96fc..4cd466a30528ddbff1acafd70b7402f3f2713d90 100644 --- a/phone/models/phonenumber.py +++ b/phone/models/phonenumber.py @@ -25,7 +25,7 @@ from noc.sa.models.service import Service from noc.project.models.project import Project from noc.sa.models.administrativedomain import AdministrativeDomain from noc.core.mongo.fields import ForeignKeyField, PlainReferenceField -from noc.lib.text import clean_number +from noc.core.text import clean_number from noc.core.resourcegroup.decorator import resourcegroup from noc.wf.models.state import State from noc.core.wf.decorator import workflow diff --git a/phone/models/phonerange.py b/phone/models/phonerange.py index 2bf1c246cca0d13a24e3b9aeaecb2d95783dbc08..971645a5b803336ddfb54f72076c82aef4725d29 100644 --- a/phone/models/phonerange.py +++ b/phone/models/phonerange.py @@ -30,7 +30,7 @@ from noc.wf.models.state import State from noc.core.wf.decorator import workflow from noc.core.model.decorator import on_save, on_delete, on_delete_check from noc.core.defer import call_later -from noc.lib.text import clean_number +from noc.core.text import clean_number from noc.core.resourcegroup.decorator import resourcegroup from .dialplan import DialPlan from .phonerangeprofile import PhoneRangeProfile diff --git a/pm/models/metrictype.py b/pm/models/metrictype.py index 56519ed09d2c9e9cc67784c0137a4c03d3af58d1..94356b5c823c9520ea3a5bfc22115f9dea3e644c 100644 --- a/pm/models/metrictype.py +++ b/pm/models/metrictype.py @@ -23,7 +23,7 @@ from .metricscope import MetricScope from noc.inv.models.capability import Capability from noc.core.mongo.fields import PlainReferenceField from noc.main.models.doccategory import category -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.prettyjson import to_json from noc.core.defer import call_later from noc.core.model.decorator import on_save diff --git a/sa/interfaces/base.py b/sa/interfaces/base.py index 68b89a8c74d21c5b27d2eb821c0311110632e32b..306b2143093649ca22574f7a9d0e4ea46e59fe82 100644 --- a/sa/interfaces/base.py +++ b/sa/interfaces/base.py @@ -14,7 +14,7 @@ import datetime import six # NOC Modules -from noc.lib.text import list_to_ranges, ranges_to_list +from noc.core.text import list_to_ranges, ranges_to_list from noc.core.ip import IPv6 from noc.core.mac import MAC from noc.lib.validators import is_ipv6 diff --git a/sa/models/action.py b/sa/models/action.py index 5f2ddbf4ea9adbc254125085b73fb4e54286b266..8f45f65b1ecaf667fd539c773768ca62680a7169 100644 --- a/sa/models/action.py +++ b/sa/models/action.py @@ -27,7 +27,7 @@ import jinja2 import cachetools # NOC modules -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.prettyjson import to_json from noc.core.ip import IP diff --git a/sa/models/actioncommands.py b/sa/models/actioncommands.py index 62a8310996d1c68657c06204a9c3fd3da39ff0ad..aa6fb8c6c82197bf2d43e38a4e8e44bfd995eefd 100644 --- a/sa/models/actioncommands.py +++ b/sa/models/actioncommands.py @@ -26,7 +26,7 @@ from mongoengine.fields import ( # NOC modules from noc.core.mongo.fields import PlainReferenceField from .profile import Profile -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path from noc.core.prettyjson import to_json from .action import Action diff --git a/sa/models/profilecheckrule.py b/sa/models/profilecheckrule.py index 60c272929ab1fd19ec1383e235f33656b527d03b..74cb92f27fe1398a87e074904a787d746a29e6ef 100644 --- a/sa/models/profilecheckrule.py +++ b/sa/models/profilecheckrule.py @@ -20,7 +20,7 @@ from noc.core.mongo.fields import PlainReferenceField from noc.sa.models.profile import Profile from noc.main.models.doccategory import category from noc.core.prettyjson import to_json -from noc.lib.text import quote_safe_path +from noc.core.text import quote_safe_path @category diff --git a/sa/profiles/APC/AOS/get_chassis_id.py b/sa/profiles/APC/AOS/get_chassis_id.py index 1295a53e2ff3193e784f8a1074e09ac66c2be56a..ef86a80d99ef2ea4be68c06341e8f6a749a50620 100644 --- a/sa/profiles/APC/AOS/get_chassis_id.py +++ b/sa/profiles/APC/AOS/get_chassis_id.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # APC.AOS.get_chassis_id # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -11,7 +11,7 @@ from noc.sa.profiles.Generic.get_chassis_id import Script as BaseScript from noc.sa.interfaces.igetchassisid import IGetChassisID from noc.core.mac import MAC from noc.core.mib import mib -from noc.lib.text import parse_kv +from noc.core.text import parse_kv class Script(BaseScript): diff --git a/sa/profiles/APC/AOS/get_inventory.py b/sa/profiles/APC/AOS/get_inventory.py index b77ac29d33bba78afab9c603aeb64f709a4149a7..94e114e864bb7eb832ccf0dabf660cb62613dfc6 100644 --- a/sa/profiles/APC/AOS/get_inventory.py +++ b/sa/profiles/APC/AOS/get_inventory.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # APC.AOS.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -11,7 +11,7 @@ import datetime # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_kv +from noc.core.text import parse_kv class Script(BaseScript): diff --git a/sa/profiles/APC/AOS/get_version.py b/sa/profiles/APC/AOS/get_version.py index 58e24002a8de5c91be4c9802aa148aa20e65f9c4..54a37f48afdbfc677d54840f5d5c21a86431e378 100644 --- a/sa/profiles/APC/AOS/get_version.py +++ b/sa/profiles/APC/AOS/get_version.py @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------- # APC.AOS.get_version # ---------------------------------------------------------------------- -# Copyright (C) 2007-2011 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import parse_kv +from noc.core.text import parse_kv from noc.core.mib import mib diff --git a/sa/profiles/Alcatel/7302/get_capabilities.py b/sa/profiles/Alcatel/7302/get_capabilities.py index 0a11f32e5d91d417416a92c39fae34931cd7266f..22a699a11f0d310a6b6980557c57e602f86d0353 100644 --- a/sa/profiles/Alcatel/7302/get_capabilities.py +++ b/sa/profiles/Alcatel/7302/get_capabilities.py @@ -2,12 +2,12 @@ # ---------------------------------------------------------------------- # Alcatel.7302.get_capabilities # ---------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error diff --git a/sa/profiles/Alcatel/7324RU/get_interfaces.py b/sa/profiles/Alcatel/7324RU/get_interfaces.py index 1218f64dc4d57391040e3917d96c85558401dd2c..8435869cef49111f8d5e1efd32a88d36fbf0ac1f 100644 --- a/sa/profiles/Alcatel/7324RU/get_interfaces.py +++ b/sa/profiles/Alcatel/7324RU/get_interfaces.py @@ -13,7 +13,7 @@ from collections import defaultdict # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.ip import IPv4 diff --git a/sa/profiles/Alcatel/7324RU/get_switchport.py b/sa/profiles/Alcatel/7324RU/get_switchport.py index b20113cc53963087253dcde8e2b37b3e126f165f..0bec8a122cbf34b34be6039c85d40dfc03e93b6a 100644 --- a/sa/profiles/Alcatel/7324RU/get_switchport.py +++ b/sa/profiles/Alcatel/7324RU/get_switchport.py @@ -13,7 +13,7 @@ from collections import defaultdict # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetswitchport import IGetSwitchport -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Alcatel/AOS/get_capabilities.py b/sa/profiles/Alcatel/AOS/get_capabilities.py index b51d6c835ae32c27f0044d84d2294ccd22a5f192..9d7d73b61ff0a07090b6219fa356f42f023a3eda 100644 --- a/sa/profiles/Alcatel/AOS/get_capabilities.py +++ b/sa/profiles/Alcatel/AOS/get_capabilities.py @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------- # Alcatel.AOS.get_capabilities # ---------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error diff --git a/sa/profiles/Alcatel/OS62xx/get_lldp_neighbors.py b/sa/profiles/Alcatel/OS62xx/get_lldp_neighbors.py index ff636600186fb5971b19b8856c55ccb44e4ae449..a4bccf08a4ad61f1034836f1c3cec43b15e2e66f 100644 --- a/sa/profiles/Alcatel/OS62xx/get_lldp_neighbors.py +++ b/sa/profiles/Alcatel/OS62xx/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Alcatel.OS62xx.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Alcatel/OS62xx/get_mac_address_table.py b/sa/profiles/Alcatel/OS62xx/get_mac_address_table.py index 13d3955102fbaca79e88c787308f8ed41c89d0fb..82254d8e5666e4a040f351f8ee78afe09c0cc199 100644 --- a/sa/profiles/Alcatel/OS62xx/get_mac_address_table.py +++ b/sa/profiles/Alcatel/OS62xx/get_mac_address_table.py @@ -2,13 +2,14 @@ # ---------------------------------------------------------------------- # Alcatel.OS62xx.get_mac_address_table # ---------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Alcatel/OS62xx/get_vlans.py b/sa/profiles/Alcatel/OS62xx/get_vlans.py index a03a9f256810df2807306369266d00bd3860b4f5..a2b68655b21fbc79c45fc7e7207435f92127ecad 100644 --- a/sa/profiles/Alcatel/OS62xx/get_vlans.py +++ b/sa/profiles/Alcatel/OS62xx/get_vlans.py @@ -2,13 +2,14 @@ # ---------------------------------------------------------------------- # Alcatel.OS62xx.get_vlans # ---------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/AlliedTelesis/AT8000S/get_capabilities.py b/sa/profiles/AlliedTelesis/AT8000S/get_capabilities.py index 4e6133f8c7e94ce49400ec32042f122289106b8a..4f433b1cf69dc6cfb903fb5416961aa1bf716cb4 100644 --- a/sa/profiles/AlliedTelesis/AT8000S/get_capabilities.py +++ b/sa/profiles/AlliedTelesis/AT8000S/get_capabilities.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # AlliedTelesis.AT8000S.get_capabilities # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/AlliedTelesis/AT8000S/get_chassis_id.py b/sa/profiles/AlliedTelesis/AT8000S/get_chassis_id.py index b29c447b0f77e58edb6de502237b50c5e377128f..211109b9f6b961e3957e77657b955a5010f09f8e 100644 --- a/sa/profiles/AlliedTelesis/AT8000S/get_chassis_id.py +++ b/sa/profiles/AlliedTelesis/AT8000S/get_chassis_id.py @@ -2,15 +2,17 @@ # --------------------------------------------------------------------- # AlliedTelesis.AT8000S.get_chassis_id # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# Python modules +import re + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetchassisid import IGetChassisID -from noc.lib.text import parse_table -import re +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/AlliedTelesis/AT8000S/get_lldp_neighbors.py b/sa/profiles/AlliedTelesis/AT8000S/get_lldp_neighbors.py index 757a0b8c9cd7a967a4f91e3606d5b2f8976f71a4..2d05702efa428c85b2db23259a922c32c14cc732 100644 --- a/sa/profiles/AlliedTelesis/AT8000S/get_lldp_neighbors.py +++ b/sa/profiles/AlliedTelesis/AT8000S/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # AlliedTelesis.AT8000S.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/AlliedTelesis/AT8100/get_interfaces.py b/sa/profiles/AlliedTelesis/AT8100/get_interfaces.py index 341c9e140d976134423c4a7a5564b1ab8f6e8b99..a818d42aca7d13831f3bdf4a6e4d26c7621f16a9 100644 --- a/sa/profiles/AlliedTelesis/AT8100/get_interfaces.py +++ b/sa/profiles/AlliedTelesis/AT8100/get_interfaces.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # AlliedTelesis.AT8100.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/AlliedTelesis/AT8100/get_vlans.py b/sa/profiles/AlliedTelesis/AT8100/get_vlans.py index 12f190a99c45c1df0b01c3561b6ce55c428c1c18..3ca1839bce186f439e7d38347238ccc3671f954d 100644 --- a/sa/profiles/AlliedTelesis/AT8100/get_vlans.py +++ b/sa/profiles/AlliedTelesis/AT8100/get_vlans.py @@ -2,15 +2,15 @@ # --------------------------------------------------------------------- # AlliedTelesis.AT8100.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # coded by azhur # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Alstec/24xx/get_arp.py b/sa/profiles/Alstec/24xx/get_arp.py index a15aa516f9ffe2f62a86c577dcfb29224a9d366e..6803836229d878a30cf71c35b645cb25e933954a 100644 --- a/sa/profiles/Alstec/24xx/get_arp.py +++ b/sa/profiles/Alstec/24xx/get_arp.py @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP from noc.sa.interfaces.base import MACAddressParameter -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Alstec/24xx/get_lldp_neighbors.py b/sa/profiles/Alstec/24xx/get_lldp_neighbors.py index 9c9bdda5352e32c5a040c7dd4c78066037d40ea2..52a402afe81b8d1de552a3042db03558f6fef22e 100644 --- a/sa/profiles/Alstec/24xx/get_lldp_neighbors.py +++ b/sa/profiles/Alstec/24xx/get_lldp_neighbors.py @@ -11,7 +11,7 @@ import re # NOC modules from noc.core.script.base import BaseScript -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.sa.interfaces.base import MACAddressParameter from noc.lib.validators import is_ipv4, is_ipv6 diff --git a/sa/profiles/Alstec/24xx/get_metrics.py b/sa/profiles/Alstec/24xx/get_metrics.py index 8cecb0311b8f1a0b235b4d4f0f0df62a401c28c5..7cf1faff40e6af77e2ef695ba9c16081e29abfd4 100644 --- a/sa/profiles/Alstec/24xx/get_metrics.py +++ b/sa/profiles/Alstec/24xx/get_metrics.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Alstec.24xx.get_metrics # --------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -11,7 +11,7 @@ import six # NOC modules from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(GetMetricsScript): diff --git a/sa/profiles/Alstec/ALS/get_lldp_neighbors.py b/sa/profiles/Alstec/ALS/get_lldp_neighbors.py index 681abfc6ea1fc3531e6ee85d312c6f850ebb9872..2dbd68ad40aed3e97728784088fa529b6da86da2 100644 --- a/sa/profiles/Alstec/ALS/get_lldp_neighbors.py +++ b/sa/profiles/Alstec/ALS/get_lldp_neighbors.py @@ -14,7 +14,7 @@ from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.sa.interfaces.base import MACAddressParameter from noc.lib.validators import is_ipv4, is_ipv6 -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Angtel/Topaz/get_lldp_neighbors.py b/sa/profiles/Angtel/Topaz/get_lldp_neighbors.py index eb705cbfa66e00b01ae9a0aefecb7f6caac10e89..b8f45649b3cc8658d2053bd4c3f494651e80b53c 100644 --- a/sa/profiles/Angtel/Topaz/get_lldp_neighbors.py +++ b/sa/profiles/Angtel/Topaz/get_lldp_neighbors.py @@ -11,7 +11,7 @@ import re # NOC modules from noc.core.script.base import BaseScript -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac from noc.core.lldp import ( diff --git a/sa/profiles/Arista/EOS/get_inventory.py b/sa/profiles/Arista/EOS/get_inventory.py index e7c76b94a0786ce2f36f8c800b4ae02476f1bb89..6c811b24dbba7fdd22e8d210ac957a5b499c8c2f 100644 --- a/sa/profiles/Arista/EOS/get_inventory.py +++ b/sa/profiles/Arista/EOS/get_inventory.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Arista.EOS.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Arista/EOS/get_vlans.py b/sa/profiles/Arista/EOS/get_vlans.py index 17cef4bf396fca5e9196906e20ae06c82c380866..4ae05197378cc9689adfa0325cca82007f77e5d2 100644 --- a/sa/profiles/Arista/EOS/get_vlans.py +++ b/sa/profiles/Arista/EOS/get_vlans.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Arista.EOS.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Audiocodes/Mediant2000/get_version.py b/sa/profiles/Audiocodes/Mediant2000/get_version.py index 7d4eeb96669fb29e689b0b2186b12f8a08f21067..3a064fa85ffe229d094413dfe53d603d1dcf2d11 100644 --- a/sa/profiles/Audiocodes/Mediant2000/get_version.py +++ b/sa/profiles/Audiocodes/Mediant2000/get_version.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # --------------------------------------------------------------------- -# Copyright (C) 2007-2011 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -10,7 +10,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import strip_html_tags +from noc.core.text import strip_html_tags class Script(BaseScript): diff --git a/sa/profiles/BDCOM/IOS/get_interfaces.py b/sa/profiles/BDCOM/IOS/get_interfaces.py index d66c19597ba738778ee8813dec95873d912d8bcc..5e6295878006e1d4661029e03ec096f604d279ec 100644 --- a/sa/profiles/BDCOM/IOS/get_interfaces.py +++ b/sa/profiles/BDCOM/IOS/get_interfaces.py @@ -2,15 +2,17 @@ # --------------------------------------------------------------------- # BDCOM.IOS.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules +import re +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table -import re +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/BDCOM/IOS/get_mac_address_table.py b/sa/profiles/BDCOM/IOS/get_mac_address_table.py index 00f22da8cc6e29f46fc0673cb5c51e7219d9d3d0..4d10a92d884496cf2ffb94d367f51ddf8ea8c19a 100644 --- a/sa/profiles/BDCOM/IOS/get_mac_address_table.py +++ b/sa/profiles/BDCOM/IOS/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # BDCOM.IOS.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.mac import MAC diff --git a/sa/profiles/BDCOM/IOS/get_vlans.py b/sa/profiles/BDCOM/IOS/get_vlans.py index 59a4d75bffd2ea9e3b2df6d92d5d61789435dde2..2f5c2e69ee8f303afd1d304699fb21a2e6923336 100644 --- a/sa/profiles/BDCOM/IOS/get_vlans.py +++ b/sa/profiles/BDCOM/IOS/get_vlans.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # BDCOM.IOS.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- - +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/BDCOM/xPON/get_interfaces.py b/sa/profiles/BDCOM/xPON/get_interfaces.py index c6cd4a5ce3cecfe0b751268ad599e6d0d3ffc700..7dc6778c35a87eb54982a2ecb4a4edf2c1d93733 100644 --- a/sa/profiles/BDCOM/xPON/get_interfaces.py +++ b/sa/profiles/BDCOM/xPON/get_interfaces.py @@ -5,15 +5,14 @@ # Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + # Python modules import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.lib.validators import is_int diff --git a/sa/profiles/BDCOM/xPON/get_mac_address_table.py b/sa/profiles/BDCOM/xPON/get_mac_address_table.py index b0e62eb71de6908bfc0f611c08f297acfa8fdfd6..f6db78f4eb9693020b029496a643b642d1a3c654 100644 --- a/sa/profiles/BDCOM/xPON/get_mac_address_table.py +++ b/sa/profiles/BDCOM/xPON/get_mac_address_table.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.mac import MAC diff --git a/sa/profiles/BDCOM/xPON/get_vlans.py b/sa/profiles/BDCOM/xPON/get_vlans.py index 3dde101db0973159a98881cc4c48e74dcc67a581..1a02f9b79af3abbd93dbc4e7f4628a88c319a87d 100644 --- a/sa/profiles/BDCOM/xPON/get_vlans.py +++ b/sa/profiles/BDCOM/xPON/get_vlans.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Carelink/SWG/get_interfaces.py b/sa/profiles/Carelink/SWG/get_interfaces.py index a5d612809a8d9508f61ed47627b6930acdf03160..015278a6d1f9155e7911852b89b218b93654d94d 100644 --- a/sa/profiles/Carelink/SWG/get_interfaces.py +++ b/sa/profiles/Carelink/SWG/get_interfaces.py @@ -14,7 +14,7 @@ from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.core.ip import IPv4 from noc.lib.validators import is_int -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Carelink/SWG/get_mac_address_table.py b/sa/profiles/Carelink/SWG/get_mac_address_table.py index 62e92fb71f53c960ef1647a8488bc0daf3fd7921..8854538ccdca0f0b204e5232266b843d8b732cac 100644 --- a/sa/profiles/Carelink/SWG/get_mac_address_table.py +++ b/sa/profiles/Carelink/SWG/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Carelink.SWG.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Carelink/SWG/get_vlans.py b/sa/profiles/Carelink/SWG/get_vlans.py index a7095b2d9a1bbc6188d18e97f02b5489e1602294..89f37f6e9f24218656f9230dc172945eccc4d714 100644 --- a/sa/profiles/Carelink/SWG/get_vlans.py +++ b/sa/profiles/Carelink/SWG/get_vlans.py @@ -10,7 +10,7 @@ from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans from noc.lib.validators import is_int -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/IOS/get_metrics.py b/sa/profiles/Cisco/IOS/get_metrics.py index 7cfc1902b14fea637fd8c8a8d8fe2bd50e39ea30..6ae0fb093ff1d916a22f2058625a1adcae4060eb 100644 --- a/sa/profiles/Cisco/IOS/get_metrics.py +++ b/sa/profiles/Cisco/IOS/get_metrics.py @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_kv +from noc.core.text import parse_kv from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics diff --git a/sa/profiles/Cisco/IOS/get_portchannel.py b/sa/profiles/Cisco/IOS/get_portchannel.py index a8ebbd3ecdbba122db9d7a5fb25d9f1803df5883..bd228aa6ad10beb5a814b5dd1a29220f4877fa9f 100644 --- a/sa/profiles/Cisco/IOS/get_portchannel.py +++ b/sa/profiles/Cisco/IOS/get_portchannel.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Cisco.IOS.get_portchannel # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -11,7 +11,7 @@ import re # NOC modules from noc.sa.profiles.Generic.get_portchannel import Script as BaseScript from noc.sa.interfaces.igetportchannel import IGetPortchannel -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/IOS/get_spanning_tree.py b/sa/profiles/Cisco/IOS/get_spanning_tree.py index ad62b1d5447b764748c6807de9fc2044bfe83eea..fd0d49a7c0d861816c701fbe4e16b09270219d80 100644 --- a/sa/profiles/Cisco/IOS/get_spanning_tree.py +++ b/sa/profiles/Cisco/IOS/get_spanning_tree.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Cisco.IOS.get_spanning_tree # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/IOS/set_switchport.py b/sa/profiles/Cisco/IOS/set_switchport.py index 493dfdd9d3e4131b5ab6bd775c4f2a6bbbba64f5..43d12dd489e0d8bf7764ccfa83ccd93738533501 100644 --- a/sa/profiles/Cisco/IOS/set_switchport.py +++ b/sa/profiles/Cisco/IOS/set_switchport.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.isetswitchport import ISetSwitchport -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges from noc.sa.profiles.Cisco.IOS.profile import MESeries diff --git a/sa/profiles/Cisco/SMB/get_arp.py b/sa/profiles/Cisco/SMB/get_arp.py index a288598de5af08ebe29c5064f768e64f8fc0d461..eb48067c5765ec6afbfbb956657dd5d2bc491eaf 100644 --- a/sa/profiles/Cisco/SMB/get_arp.py +++ b/sa/profiles/Cisco/SMB/get_arp.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/SMB/get_interfaces.py b/sa/profiles/Cisco/SMB/get_interfaces.py index 8562fd286c645e9423afbf5dc6933a7ef992a7fc..3532fd0ca94c825cff4e5aa5acf34a73fb35de23 100644 --- a/sa/profiles/Cisco/SMB/get_interfaces.py +++ b/sa/profiles/Cisco/SMB/get_interfaces.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/SMB/get_lldp_neighbors.py b/sa/profiles/Cisco/SMB/get_lldp_neighbors.py index b65d6c28139238cabd397f34a506f3d23ef56a7b..b45c3dfc75d4f080cf5b6960425fec7f4fcabbc7 100644 --- a/sa/profiles/Cisco/SMB/get_lldp_neighbors.py +++ b/sa/profiles/Cisco/SMB/get_lldp_neighbors.py @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_int, is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Cisco/SMB/get_portchannel.py b/sa/profiles/Cisco/SMB/get_portchannel.py index 4907623095d66a0b838399c9cd0c6aa8557561f1..fad20c0cfa3daec5ebe629c1b8d61bb4a8466dec 100644 --- a/sa/profiles/Cisco/SMB/get_portchannel.py +++ b/sa/profiles/Cisco/SMB/get_portchannel.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetportchannel import IGetPortchannel -from noc.lib.text import split_alnum +from noc.core.text import split_alnum class Script(BaseScript): diff --git a/sa/profiles/Cisco/SMB/get_spanning_tree.py b/sa/profiles/Cisco/SMB/get_spanning_tree.py index 84ff3d05158b5d235a70fbd172cf82b2d5c72895..f5f9896814ca543de368f0cc7d9632d4af35efaa 100644 --- a/sa/profiles/Cisco/SMB/get_spanning_tree.py +++ b/sa/profiles/Cisco/SMB/get_spanning_tree.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/DLink/DxS/get_chassis_id.py b/sa/profiles/DLink/DxS/get_chassis_id.py index c79893c93abd205d1ed6859c7632ae0b52381e34..40b27069429bdb7df8107886bf3d235399a0f457 100644 --- a/sa/profiles/DLink/DxS/get_chassis_id.py +++ b/sa/profiles/DLink/DxS/get_chassis_id.py @@ -2,17 +2,19 @@ # --------------------------------------------------------------------- # DLink.DxS.get_chassis_id # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# Python modules +import re + +# NOC modules from noc.sa.profiles.Generic.get_chassis_id import Script as BaseScript from noc.sa.interfaces.igetchassisid import IGetChassisID from noc.lib.validators import is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.mib import mib -import re class Script(BaseScript): diff --git a/sa/profiles/DLink/DxS_Industrial_CLI/get_arp.py b/sa/profiles/DLink/DxS_Industrial_CLI/get_arp.py index 2fc5e1a75e761e44efc47ecf98b21f9145ef271c..6dfa15ee461a85feeef31a939c6f8f9917821441 100644 --- a/sa/profiles/DLink/DxS_Industrial_CLI/get_arp.py +++ b/sa/profiles/DLink/DxS_Industrial_CLI/get_arp.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # DLink.DxS_Industrial_CLI.get_arp # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/DLink/DxS_Industrial_CLI/get_lldp_neighbors.py b/sa/profiles/DLink/DxS_Industrial_CLI/get_lldp_neighbors.py index 04f7413358a9bb17d1e7eb368d2948fe371a15b7..0aff50e9f30e163a90db88b054a3b023d394ead3 100644 --- a/sa/profiles/DLink/DxS_Industrial_CLI/get_lldp_neighbors.py +++ b/sa/profiles/DLink/DxS_Industrial_CLI/get_lldp_neighbors.py @@ -2,11 +2,10 @@ # --------------------------------------------------------------------- # DLink.DxS_Industrial_CLI.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + # Python modules import re @@ -15,7 +14,7 @@ from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.sa.interfaces.base import MACAddressParameter from noc.sa.interfaces.base import IPv4Parameter -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/DLink/DxS_Industrial_CLI/get_mac_address_table.py b/sa/profiles/DLink/DxS_Industrial_CLI/get_mac_address_table.py index 0c169f2547a99ed48245e84ce2bc28333b6d7963..981d2f449dc3e7ac3c3a0d28486ba0f99b560155 100644 --- a/sa/profiles/DLink/DxS_Industrial_CLI/get_mac_address_table.py +++ b/sa/profiles/DLink/DxS_Industrial_CLI/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # DLink.DxS_Industrial_CLI.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/EdgeCore/ES/confdb/normalizer.py b/sa/profiles/EdgeCore/ES/confdb/normalizer.py index 7521cc3f23d9c216c6d0a790974e315af4411c50..3a522ff2c714489c07c333025687324d7ae42517 100644 --- a/sa/profiles/EdgeCore/ES/confdb/normalizer.py +++ b/sa/profiles/EdgeCore/ES/confdb/normalizer.py @@ -8,7 +8,7 @@ # NOC modules from noc.core.confdb.normalizer.base import BaseNormalizer, match, ANY, REST -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list class ESNormalizer(BaseNormalizer): diff --git a/sa/profiles/Eltex/ESR/get_arp.py b/sa/profiles/Eltex/ESR/get_arp.py index ed76dd5263262f24f76a6ffdc509199f0650079d..bb22dab5fa3e2f88e5477c45e2137388fb743b3b 100644 --- a/sa/profiles/Eltex/ESR/get_arp.py +++ b/sa/profiles/Eltex/ESR/get_arp.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.ESR.get_arp # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/ESR/get_interface_status.py b/sa/profiles/Eltex/ESR/get_interface_status.py index 9782490a09e7f4aa0cd9916358869ca815e8467c..27a01b388a93899a082eafb95b1112487e3b8df0 100644 --- a/sa/profiles/Eltex/ESR/get_interface_status.py +++ b/sa/profiles/Eltex/ESR/get_interface_status.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfacestatus import IGetInterfaceStatus -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/ESR/get_interfaces.py b/sa/profiles/Eltex/ESR/get_interfaces.py index 4bfd2bee68bb39ba1da5e8d00d9c58a3351f862b..1eab14a1afaeb623e50d5881dd357f6d9a8d08a7 100644 --- a/sa/profiles/Eltex/ESR/get_interfaces.py +++ b/sa/profiles/Eltex/ESR/get_interfaces.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/ESR/get_ipv6_neighbor.py b/sa/profiles/Eltex/ESR/get_ipv6_neighbor.py index e3b66a76c74938efaf0db387248860bd189f026e..300557ee9725f88ef6ebe742d39f43130c127aef 100644 --- a/sa/profiles/Eltex/ESR/get_ipv6_neighbor.py +++ b/sa/profiles/Eltex/ESR/get_ipv6_neighbor.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetipv6neighbor import IGetIPv6Neighbor -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/ESR/get_mac_address_table.py b/sa/profiles/Eltex/ESR/get_mac_address_table.py index b6c769fa783b50798261ccaf4fa60899b1d2683c..ce05fc097a08952cc217045435657f76902dfa25 100644 --- a/sa/profiles/Eltex/ESR/get_mac_address_table.py +++ b/sa/profiles/Eltex/ESR/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.ESR.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/ESR/get_vlans.py b/sa/profiles/Eltex/ESR/get_vlans.py index d423fbfaf1325286b8ad18758d8eda9f5c57f50b..371e15e5dbc2b5729f97777eb537d540271cb0b2 100644 --- a/sa/profiles/Eltex/ESR/get_vlans.py +++ b/sa/profiles/Eltex/ESR/get_vlans.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.ESR.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/LTP/get_interfaces.py b/sa/profiles/Eltex/LTP/get_interfaces.py index f152b8b2ce9ebb156bc681adef83446533495aed..bea9de07a35052cd17e8d4988b218a49590b3016 100644 --- a/sa/profiles/Eltex/LTP/get_interfaces.py +++ b/sa/profiles/Eltex/LTP/get_interfaces.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Eltex.LTP.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.core.ip import IPv4 -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/LTP/get_lldp_neighbors.py b/sa/profiles/Eltex/LTP/get_lldp_neighbors.py index ef5243fa3562f0b14242f788166cff8a3281b15c..b900a798192e2686b2537fe46218737aa444d1aa 100644 --- a/sa/profiles/Eltex/LTP/get_lldp_neighbors.py +++ b/sa/profiles/Eltex/LTP/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Eltex.LTP.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -14,7 +14,7 @@ from noc.sa.profiles.Generic.get_lldp_neighbors import Script as BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.sa.interfaces.base import MACAddressParameter from noc.lib.validators import is_int, is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/LTP/get_mac_address_table.py b/sa/profiles/Eltex/LTP/get_mac_address_table.py index 1edc26f273fd21bce4e6ef11fe304dfc883f0b1f..f98ec2a8ac0ab6caf23180cdc4435c5744972395 100644 --- a/sa/profiles/Eltex/LTP/get_mac_address_table.py +++ b/sa/profiles/Eltex/LTP/get_mac_address_table.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Eltex.LTP.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MA4000/get_dom_status.py b/sa/profiles/Eltex/MA4000/get_dom_status.py index e7b5f9f6ec2777deb42f31daaaa531084e365505..a381b0b9e15ca48207f6a9284c376ccb192be730 100644 --- a/sa/profiles/Eltex/MA4000/get_dom_status.py +++ b/sa/profiles/Eltex/MA4000/get_dom_status.py @@ -2,15 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MA4000.get_dom_status # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- - # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetdomstatus import IGetDOMStatus -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MA4000/get_interfaces.py b/sa/profiles/Eltex/MA4000/get_interfaces.py index 32f9dde45022104b024141f16e2844e5617588cc..ce03ee3b52394605dbaf7793bfb560e4ea970689 100644 --- a/sa/profiles/Eltex/MA4000/get_interfaces.py +++ b/sa/profiles/Eltex/MA4000/get_interfaces.py @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.core.ip import IPv4 -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MA4000/get_inventory.py b/sa/profiles/Eltex/MA4000/get_inventory.py index 8ed248c1b8f48b72e4ca85424b2abb9305c79913..1c56a0a990411b8dd649f7048f2a9c4236baa7a4 100644 --- a/sa/profiles/Eltex/MA4000/get_inventory.py +++ b/sa/profiles/Eltex/MA4000/get_inventory.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MA4000/get_lldp_neighbors.py b/sa/profiles/Eltex/MA4000/get_lldp_neighbors.py index fed482129b078efd4994eecc69ab946d3c060480..c96dfb459ad0ae5578dbd960b8c448885e6aaa5b 100644 --- a/sa/profiles/Eltex/MA4000/get_lldp_neighbors.py +++ b/sa/profiles/Eltex/MA4000/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Eltex.MA4000.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.lldp import ( LLDP_CHASSIS_SUBTYPE_MAC, LLDP_CHASSIS_SUBTYPE_NETWORK_ADDRESS, diff --git a/sa/profiles/Eltex/MA4000/get_local_users.py b/sa/profiles/Eltex/MA4000/get_local_users.py index ff3df62d156efb2b172a7c8a70eeff994748d551..643525c37c89ffe84b743e4b3bdcc4fc41a171e1 100644 --- a/sa/profiles/Eltex/MA4000/get_local_users.py +++ b/sa/profiles/Eltex/MA4000/get_local_users.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MA4000.get_local_users # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlocalusers import IGetLocalUsers -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MA4000/get_mac_address_table.py b/sa/profiles/Eltex/MA4000/get_mac_address_table.py index 403bf6e2dcebe456cf91e54f3c9ab339a898ed5e..b9c8891a453b6be8441974250d0c26fcccbdc1eb 100644 --- a/sa/profiles/Eltex/MA4000/get_mac_address_table.py +++ b/sa/profiles/Eltex/MA4000/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MA4000.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES/confdb/normalizer.py b/sa/profiles/Eltex/MES/confdb/normalizer.py index 84fc4cb3c10d4933e9a1a680cfcb349ee3ec6d21..ba9de38eb0e0721395fe91cf6ff9647ce7ded9f4 100644 --- a/sa/profiles/Eltex/MES/confdb/normalizer.py +++ b/sa/profiles/Eltex/MES/confdb/normalizer.py @@ -8,7 +8,7 @@ # NOC modules from noc.core.confdb.normalizer.base import BaseNormalizer, match, ANY, REST -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list class MESNormalizer(BaseNormalizer): diff --git a/sa/profiles/Eltex/MES/get_capabilities.py b/sa/profiles/Eltex/MES/get_capabilities.py index 2d33fc73bbb32737b056a160be45fba0f1f55477..27f0a156193162cffcfaf62b47508376f62939d7 100644 --- a/sa/profiles/Eltex/MES/get_capabilities.py +++ b/sa/profiles/Eltex/MES/get_capabilities.py @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error diff --git a/sa/profiles/Eltex/MES/get_interfaces.py b/sa/profiles/Eltex/MES/get_interfaces.py index 0eeb17cfc61e549cd6d89a615aafcd3d04248701..31fe7ab111e1bc793582ce3dfb605b8d3395ed4c 100644 --- a/sa/profiles/Eltex/MES/get_interfaces.py +++ b/sa/profiles/Eltex/MES/get_interfaces.py @@ -15,7 +15,7 @@ import time from noc.sa.profiles.Generic.get_interfaces import Script as BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.sa.interfaces.base import MACAddressParameter -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.mac import MAC from noc.core.mib import mib from noc.core.ip import IPv4 diff --git a/sa/profiles/Eltex/MES/get_inventory.py b/sa/profiles/Eltex/MES/get_inventory.py index b312f0403e5e91313a88b3cebfb1d06c480fac03..d06c95a83faa2a5a7b3462c18000f1437acd268c 100644 --- a/sa/profiles/Eltex/MES/get_inventory.py +++ b/sa/profiles/Eltex/MES/get_inventory.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.lib.validators import is_int diff --git a/sa/profiles/Eltex/MES/get_lldp_neighbors.py b/sa/profiles/Eltex/MES/get_lldp_neighbors.py index 5a1a6e9b989db8b9af79baa8ab2734e1127cb8f8..49bcb986fc8d1e406b92fa0c963bcbebeae71658 100644 --- a/sa/profiles/Eltex/MES/get_lldp_neighbors.py +++ b/sa/profiles/Eltex/MES/get_lldp_neighbors.py @@ -18,7 +18,7 @@ from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.sa.interfaces.base import MACAddressParameter from noc.lib.validators import is_int, is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.mac import MAC from noc.core.mib import mib from noc.core.lldp import ( diff --git a/sa/profiles/Eltex/MES/get_spanning_tree.py b/sa/profiles/Eltex/MES/get_spanning_tree.py index 29ab62bef3d797da62b90e5b9842a900f6d9d696..00bcb7262424c218ffcd6450f7a387cde57b7efe 100644 --- a/sa/profiles/Eltex/MES/get_spanning_tree.py +++ b/sa/profiles/Eltex/MES/get_spanning_tree.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES/get_switchport.py b/sa/profiles/Eltex/MES/get_switchport.py index 8981c0643dc5dd1f20632847b367f697b8f042ce..2cad671a4d8ce604981a178d0fc65120d6d5dfe2 100644 --- a/sa/profiles/Eltex/MES/get_switchport.py +++ b/sa/profiles/Eltex/MES/get_switchport.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Eltex.MES.get_switchport # --------------------------------------------------------------------- -# Copyright (C) 2007-2015 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetswitchport import IGetSwitchport -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES/set_switchport.py b/sa/profiles/Eltex/MES/set_switchport.py index 0da7f223d67b2b02f09e00fb921a3029d9574603..ac5ee54e1eebac8ad29d3f23b27e8b243d477264 100644 --- a/sa/profiles/Eltex/MES/set_switchport.py +++ b/sa/profiles/Eltex/MES/set_switchport.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MES.set_switchport # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.isetswitchport import ISetSwitchport -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_arp.py b/sa/profiles/Eltex/MES5448/get_arp.py index 77edd6f11b5bd3368e7cb54b2113b56bd897bcee..5bffe1ad19dfc33dd129b5f56afb43277ab940f8 100644 --- a/sa/profiles/Eltex/MES5448/get_arp.py +++ b/sa/profiles/Eltex/MES5448/get_arp.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MES5448.get_arp # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_capabilities.py b/sa/profiles/Eltex/MES5448/get_capabilities.py index b4a57e9f4d5586ee314f9f3086009d5868d27cdb..63ada73633c8dc9becee7a140fff7656db64a1ee 100644 --- a/sa/profiles/Eltex/MES5448/get_capabilities.py +++ b/sa/profiles/Eltex/MES5448/get_capabilities.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_interfaces.py b/sa/profiles/Eltex/MES5448/get_interfaces.py index 492662b8288876c80b8a962d57175a6301840bb8..67a510d79061ceeed97de3b6dd2af9dc3d4d606f 100644 --- a/sa/profiles/Eltex/MES5448/get_interfaces.py +++ b/sa/profiles/Eltex/MES5448/get_interfaces.py @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.core.ip import IPv4 -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_inventory.py b/sa/profiles/Eltex/MES5448/get_inventory.py index d3d3b66da67ff59034d3770b734a8ab086ffa4e4..c78d697eb638e4138c9120389dfd47c7e19b9e72 100644 --- a/sa/profiles/Eltex/MES5448/get_inventory.py +++ b/sa/profiles/Eltex/MES5448/get_inventory.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_lacp_neighbors.py b/sa/profiles/Eltex/MES5448/get_lacp_neighbors.py index bd914f4e84bc6a7ddfc9b3eea35fb9cbf51263cd..735e206eee2f5bd05701268dc455153d85c45c5a 100644 --- a/sa/profiles/Eltex/MES5448/get_lacp_neighbors.py +++ b/sa/profiles/Eltex/MES5448/get_lacp_neighbors.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlacpneighbors import IGetLACPNeighbors -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_lldp_neighbors.py b/sa/profiles/Eltex/MES5448/get_lldp_neighbors.py index e4388b9eef21b5c91046afae9aaf82a86b18b584..8ff6d5afe2bdd4288080210a0d88e7b7b4d14952 100644 --- a/sa/profiles/Eltex/MES5448/get_lldp_neighbors.py +++ b/sa/profiles/Eltex/MES5448/get_lldp_neighbors.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_mac_address_table.py b/sa/profiles/Eltex/MES5448/get_mac_address_table.py index 2ecb98e67a9690d9e4b58025d54aa002fba6bab8..90543bb46cb86fa9721a3287eecfeee9fa4c4b55 100644 --- a/sa/profiles/Eltex/MES5448/get_mac_address_table.py +++ b/sa/profiles/Eltex/MES5448/get_mac_address_table.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MES5448.get_mac_address_table # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_portchannel.py b/sa/profiles/Eltex/MES5448/get_portchannel.py index bd8ade34094f107535d6735b3f82b639ab8acc36..9d4ec2d9990bea2264050a8eaa7709fb8b01088a 100644 --- a/sa/profiles/Eltex/MES5448/get_portchannel.py +++ b/sa/profiles/Eltex/MES5448/get_portchannel.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MES5448.get_portchannel # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetportchannel import IGetPortchannel -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Eltex/MES5448/get_vlans.py b/sa/profiles/Eltex/MES5448/get_vlans.py index 23b1079200989a2cd8edf26594fbc9adbc5c346f..de8be6442f99c60e4dd169bee1d0f5d5d535eb74 100644 --- a/sa/profiles/Eltex/MES5448/get_vlans.py +++ b/sa/profiles/Eltex/MES5448/get_vlans.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Eltex.MES5448.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Ericsson/MINI_LINK/get_mac_address_table.py b/sa/profiles/Ericsson/MINI_LINK/get_mac_address_table.py index e6fe93589f563d3c112a6f810a9f043994d994e0..91bdba133fb37e7546fd000a7fa7f9ecd8c3a53a 100644 --- a/sa/profiles/Ericsson/MINI_LINK/get_mac_address_table.py +++ b/sa/profiles/Ericsson/MINI_LINK/get_mac_address_table.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Ericsson/SEOS/get_mac_address_table.py b/sa/profiles/Ericsson/SEOS/get_mac_address_table.py index 5db556f9659467dc6b3abf47422a8104c5115923..eb22304e33c3bc5ef86a36db8cee3ccd33226047 100644 --- a/sa/profiles/Ericsson/SEOS/get_mac_address_table.py +++ b/sa/profiles/Ericsson/SEOS/get_mac_address_table.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.lib.validators import is_int diff --git a/sa/profiles/Extreme/XOS/get_capabilities.py b/sa/profiles/Extreme/XOS/get_capabilities.py index 054bb9830746dd8fa03a480b8ca5864f76615b3b..483e8e13e439aed9afd1567b54376541645454ee 100644 --- a/sa/profiles/Extreme/XOS/get_capabilities.py +++ b/sa/profiles/Extreme/XOS/get_capabilities.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Extreme.XOS.get_capabilities # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Extreme/XOS/get_dom_status.py b/sa/profiles/Extreme/XOS/get_dom_status.py index 097d4a2da663e8c70ff88e055d77e6168c0943b1..ddd46f3bb3af4bf2beb20e1aa1e30497bddba731 100644 --- a/sa/profiles/Extreme/XOS/get_dom_status.py +++ b/sa/profiles/Extreme/XOS/get_dom_status.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetdomstatus import IGetDOMStatus -from noc.lib.text import parse_kv +from noc.core.text import parse_kv from noc.lib.validators import is_int from noc.core.convert.dbm import mw2dbm diff --git a/sa/profiles/Extreme/XOS/get_inventory.py b/sa/profiles/Extreme/XOS/get_inventory.py index 9a6e7449d38ac696ebc9187b45ae2a3236c2fdad..e9b4751fc718916f4d98ab66254424113f4a981c 100644 --- a/sa/profiles/Extreme/XOS/get_inventory.py +++ b/sa/profiles/Extreme/XOS/get_inventory.py @@ -2,10 +2,11 @@ # --------------------------------------------------------------------- # Extreme.XOS.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules import re import datetime from collections import defaultdict @@ -13,7 +14,7 @@ from collections import defaultdict # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_kv +from noc.core.text import parse_kv from noc.lib.validators import is_int diff --git a/sa/profiles/Force10/FTOS/get_spanning_tree.py b/sa/profiles/Force10/FTOS/get_spanning_tree.py index 8736523154d90aacf121b7202ddab6395390d403..4617e254b39dd20323a3e1d5f343147a8464547d 100644 --- a/sa/profiles/Force10/FTOS/get_spanning_tree.py +++ b/sa/profiles/Force10/FTOS/get_spanning_tree.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Force10/FTOS/get_vlans.py b/sa/profiles/Force10/FTOS/get_vlans.py index 0e2d5507a36fed9798c3b63126897511b0a074e5..f1360824f80d88da4499c8956c63da75f1066666 100644 --- a/sa/profiles/Force10/FTOS/get_vlans.py +++ b/sa/profiles/Force10/FTOS/get_vlans.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Force10/SFTOS/get_arp.py b/sa/profiles/Force10/SFTOS/get_arp.py index cc500897f7c69ee8b50ea4904fc1183930ed511e..a617b79b4951bab7a823082c2b88ddf7df76b917 100644 --- a/sa/profiles/Force10/SFTOS/get_arp.py +++ b/sa/profiles/Force10/SFTOS/get_arp.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Force10.SFTOS.get_arp # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetarp import IGetARP -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Force10/SFTOS/get_vlans.py b/sa/profiles/Force10/SFTOS/get_vlans.py index fc39517994739352ef797fb7d4e6ca4f7234ffb5..906b4a2ea2c82166742554b3c78dff302ae8ac11 100644 --- a/sa/profiles/Force10/SFTOS/get_vlans.py +++ b/sa/profiles/Force10/SFTOS/get_vlans.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Force10.SFTOS.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/HP/1910/set_switchport.py b/sa/profiles/HP/1910/set_switchport.py index 95fbbb6680473f1153b93cf8e8200e25a3c8e325..2358c4abe1b848a59b50d15262f52b883cf9230e 100644 --- a/sa/profiles/HP/1910/set_switchport.py +++ b/sa/profiles/HP/1910/set_switchport.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # HP.1910.set_switchport # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.isetswitchport import ISetSwitchport -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges class Script(BaseScript): diff --git a/sa/profiles/HP/GbE2/get_mac_address_table.py b/sa/profiles/HP/GbE2/get_mac_address_table.py index 278e104595d418834aede41a2124419a67f44d31..3b11bd38f892f7aa7daf9aea4bd92d29fce3e56c 100644 --- a/sa/profiles/HP/GbE2/get_mac_address_table.py +++ b/sa/profiles/HP/GbE2/get_mac_address_table.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/HP/ProCurve/get_inventory.py b/sa/profiles/HP/ProCurve/get_inventory.py index 2d7d016cc09739fe84b54408ef21e7e3c2d73980..f6109968297b60497df3eeeb768dc6075d4b47e6 100644 --- a/sa/profiles/HP/ProCurve/get_inventory.py +++ b/sa/profiles/HP/ProCurve/get_inventory.py @@ -5,13 +5,14 @@ # Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- + # Python modules import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/HP/ProCurve/get_spanning_tree.py b/sa/profiles/HP/ProCurve/get_spanning_tree.py index b95dba3c7bfc36c9dcc5186c9383b6f5a6316eb4..e1633c83cef768e328764a3ebb4ccd794df100a0 100644 --- a/sa/profiles/HP/ProCurve/get_spanning_tree.py +++ b/sa/profiles/HP/ProCurve/get_spanning_tree.py @@ -15,7 +15,7 @@ import six # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges class Script(BaseScript): diff --git a/sa/profiles/HP/ProCurve/get_vlans.py b/sa/profiles/HP/ProCurve/get_vlans.py index f058fbe88d4c25c90248ae0488b4defeecdce998..6f456334da12d2009633d902dad72ccb38cebc9b 100644 --- a/sa/profiles/HP/ProCurve/get_vlans.py +++ b/sa/profiles/HP/ProCurve/get_vlans.py @@ -2,15 +2,14 @@ # --------------------------------------------------------------------- # HP.ProCurve.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2010 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Huawei/MA5600T/get_cpe.py b/sa/profiles/Huawei/MA5600T/get_cpe.py index 394f6b82119c75bde88fbe36274bb5c729927ccf..7c073a9554a85b534135537c5c55bdfac46ad0ef 100644 --- a/sa/profiles/Huawei/MA5600T/get_cpe.py +++ b/sa/profiles/Huawei/MA5600T/get_cpe.py @@ -2,18 +2,19 @@ # --------------------------------------------------------------------- # Huawei.MA5600T.get_cpe # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules import re import six # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetcpe import IGetCPE -from noc.lib.text import parse_table_header -from noc.lib.text import parse_kv +from noc.core.text import parse_table_header +from noc.core.text import parse_kv from noc.core.mib import mib diff --git a/sa/profiles/Huawei/MA5600T/get_cpe_status.py b/sa/profiles/Huawei/MA5600T/get_cpe_status.py index 8913bd337f5d9e548b745898a032abdf615d0571..edc67d6b7c1da4e84e3b3cf54c4243a01f709bc3 100644 --- a/sa/profiles/Huawei/MA5600T/get_cpe_status.py +++ b/sa/profiles/Huawei/MA5600T/get_cpe_status.py @@ -2,17 +2,18 @@ # --------------------------------------------------------------------- # Huawei.MA5600T.get_cpe_status # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules import re import six # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetcpe import IGetCPE -from noc.lib.text import parse_table_header +from noc.core.text import parse_table_header from noc.core.mib import mib diff --git a/sa/profiles/Huawei/MA5600T/get_metrics.py b/sa/profiles/Huawei/MA5600T/get_metrics.py index 606344d452153224703d9f4475d4e064814502f2..54384f33979446e661e87f5000ee4aad9f21dfb4 100644 --- a/sa/profiles/Huawei/MA5600T/get_metrics.py +++ b/sa/profiles/Huawei/MA5600T/get_metrics.py @@ -12,7 +12,7 @@ import six # NOC modules from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics -from noc.lib.text import parse_kv +from noc.core.text import parse_kv from noc.core.mib import mib SNMP_UNKNOWN_VALUE = 2147483647 diff --git a/sa/profiles/Huawei/VRP/get_dom_status.py b/sa/profiles/Huawei/VRP/get_dom_status.py index 92779604892bc0791f91754304ece6acac5ee978..07fc4b9f760cc3c3bd48772e0c0a8094542a30c3 100644 --- a/sa/profiles/Huawei/VRP/get_dom_status.py +++ b/sa/profiles/Huawei/VRP/get_dom_status.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Huawei.VRP.get_dom_status # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetdomstatus import IGetDOMStatus -from noc.lib.text import parse_table, parse_kv +from noc.core.text import parse_table, parse_kv class Script(BaseScript): diff --git a/sa/profiles/Huawei/VRP/get_inventory.py b/sa/profiles/Huawei/VRP/get_inventory.py index 4893ed46955c00e9f91acef0f6e13ec090e00506..6a82ba2e40aa26c3d836d4632f0ca6db89ee3e34 100644 --- a/sa/profiles/Huawei/VRP/get_inventory.py +++ b/sa/profiles/Huawei/VRP/get_inventory.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Huawei.VRP.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -15,7 +15,7 @@ from six.moves import zip # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_kv +from noc.core.text import parse_kv class Script(BaseScript): diff --git a/sa/profiles/Huawei/VRP/get_lldp_neighbors.py b/sa/profiles/Huawei/VRP/get_lldp_neighbors.py index e01daf562b4d0bb807f513377d5538e293cd4fc6..0ccffc2345757f26b68d61beb4ca3f83e08eaa32 100644 --- a/sa/profiles/Huawei/VRP/get_lldp_neighbors.py +++ b/sa/profiles/Huawei/VRP/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Huawei.VRP.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors, MACAddressParameter -from noc.lib.text import parse_kv +from noc.core.text import parse_kv class Script(BaseScript): diff --git a/sa/profiles/Iskratel/ESCOM/get_interfaces.py b/sa/profiles/Iskratel/ESCOM/get_interfaces.py index 95150ab7f64ecf657093388f09481cc618dc9232..c7ee7a8c225357e91f663fd96d40ecff2a723a09 100644 --- a/sa/profiles/Iskratel/ESCOM/get_interfaces.py +++ b/sa/profiles/Iskratel/ESCOM/get_interfaces.py @@ -2,18 +2,20 @@ # --------------------------------------------------------------------- # Iskratel.ESCOM.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # Python modules import re + +# Third-party modules import six # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Iskratel/ESCOM/get_lldp_neighbors.py b/sa/profiles/Iskratel/ESCOM/get_lldp_neighbors.py index c0793e096c6f09f39abe4ee1be3d4f3a401041ee..dfcc0250182105275a9c476ec16b704cf1d71a02 100644 --- a/sa/profiles/Iskratel/ESCOM/get_lldp_neighbors.py +++ b/sa/profiles/Iskratel/ESCOM/get_lldp_neighbors.py @@ -13,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Iskratel/MSAN/get_lldp_neighbors.py b/sa/profiles/Iskratel/MSAN/get_lldp_neighbors.py index 60ae91c855c389f29012f894eb0aba823e722ae0..e32a4f5f92e08a9805dde4f2fabdf8b6795406d7 100644 --- a/sa/profiles/Iskratel/MSAN/get_lldp_neighbors.py +++ b/sa/profiles/Iskratel/MSAN/get_lldp_neighbors.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Iskratel.MSAN.get_lldp_neighbors # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Juniper/JUNOS/get_bfd_sessions.py b/sa/profiles/Juniper/JUNOS/get_bfd_sessions.py index 158add27646b2d7a40b7258d66955ad871dd6d91..f012d6f37bf8aa3943bbfc794b57dbeb958f5e6e 100644 --- a/sa/profiles/Juniper/JUNOS/get_bfd_sessions.py +++ b/sa/profiles/Juniper/JUNOS/get_bfd_sessions.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Juniper.JUNOS.get_bfd_sessions # --------------------------------------------------------------------- -# Copyright (C) 2007-2013 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetbfdsessions import IGetBFDSessions -from noc.lib.text import find_indented +from noc.core.text import find_indented class Script(BaseScript): diff --git a/sa/profiles/Juniper/JUNOSe/get_metrics.py b/sa/profiles/Juniper/JUNOSe/get_metrics.py index a793b379552e458920b7926795575d96f0223366..37e531291811fef69f4d07d07f2ae020565097af 100644 --- a/sa/profiles/Juniper/JUNOSe/get_metrics.py +++ b/sa/profiles/Juniper/JUNOSe/get_metrics.py @@ -2,18 +2,20 @@ # --------------------------------------------------------------------- # Juniper.JUNOSe.get_metrics # --------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # Python modules from __future__ import absolute_import + +# Third-party modules import six # NOC modules from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics from .oidrules.slot import SlotRule -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(GetMetricsScript): diff --git a/sa/profiles/Linksys/VoIP/get_chassis_id.py b/sa/profiles/Linksys/VoIP/get_chassis_id.py index 374fd9e8517046b8bc19c0989b16c603b3a2634e..d2297073010b0fe07d99adcd22c91cd86887bbe9 100644 --- a/sa/profiles/Linksys/VoIP/get_chassis_id.py +++ b/sa/profiles/Linksys/VoIP/get_chassis_id.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Linksys.VoIP.get_chassis_id # --------------------------------------------------------------------- -# Copyright (C) 2007-2012 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetchassisid import IGetChassisID -from noc.lib.text import strip_html_tags +from noc.core.text import strip_html_tags class Script(BaseScript): diff --git a/sa/profiles/Linksys/VoIP/get_config.py b/sa/profiles/Linksys/VoIP/get_config.py index 8abaf371366dd5921e10490c7c806cbad0e0e0ee..4736a060bb753663d24cf28b364dc1c582bdbb1d 100644 --- a/sa/profiles/Linksys/VoIP/get_config.py +++ b/sa/profiles/Linksys/VoIP/get_config.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Linksys.VoIP.get_config # --------------------------------------------------------------------- -# Copyright (C) 2007-2012 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetconfig import IGetConfig -from noc.lib.text import strip_html_tags +from noc.core.text import strip_html_tags class Script(BaseScript): diff --git a/sa/profiles/Linksys/VoIP/get_version.py b/sa/profiles/Linksys/VoIP/get_version.py index 34cd75aa3cf05569a50b2af9b71dda0e9cf21b35..dbf1e200c3b604ad3de914c8ad1c8b447852456e 100644 --- a/sa/profiles/Linksys/VoIP/get_version.py +++ b/sa/profiles/Linksys/VoIP/get_version.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Linksys.VoIP.get_version # --------------------------------------------------------------------- -# Copyright (C) 2007-2012 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import strip_html_tags +from noc.core.text import strip_html_tags class Script(BaseScript): diff --git a/sa/profiles/Nateks/FlexGainACE16/get_version.py b/sa/profiles/Nateks/FlexGainACE16/get_version.py index 7834581a55dbe1abbbacd52e4862740a1a531f81..c61d54d999ea8da6499bb1c3a5f9b1bbce03d7e6 100644 --- a/sa/profiles/Nateks/FlexGainACE16/get_version.py +++ b/sa/profiles/Nateks/FlexGainACE16/get_version.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import parse_kv +from noc.core.text import parse_kv class Script(BaseScript): diff --git a/sa/profiles/Planet/WGSD/get_capabilities.py b/sa/profiles/Planet/WGSD/get_capabilities.py index 4babf0840bfb222db1f05e035bbd81b172496a1c..517efb82a800de813583daa9e749edf534cd8b70 100644 --- a/sa/profiles/Planet/WGSD/get_capabilities.py +++ b/sa/profiles/Planet/WGSD/get_capabilities.py @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error diff --git a/sa/profiles/Planet/WGSD/get_interfaces.py b/sa/profiles/Planet/WGSD/get_interfaces.py index 6f530b6778c92b4adcf2f8b05339272410c5695e..9ba56e2d4374bacf9bbbaddacf4594a67541d283 100644 --- a/sa/profiles/Planet/WGSD/get_interfaces.py +++ b/sa/profiles/Planet/WGSD/get_interfaces.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Planet.WGSD.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.sa.interfaces.base import MACAddressParameter diff --git a/sa/profiles/Planet/WGSD/get_spanning_tree.py b/sa/profiles/Planet/WGSD/get_spanning_tree.py index 9ec501472fb9fd20db43f5340efec617475379df..3ea46b0ef2ada47995cddf7535eae9db76ae06af 100644 --- a/sa/profiles/Planet/WGSD/get_spanning_tree.py +++ b/sa/profiles/Planet/WGSD/get_spanning_tree.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Planet.WGSD.get_spanning_tree # --------------------------------------------------------------------- -# Copyright (C) 2007-2015 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetspanningtree import IGetSpanningTree -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Qtech/QOS/get_interfaces.py b/sa/profiles/Qtech/QOS/get_interfaces.py index 1ccf13b06e89a043fd42eb056e1939a839517ee7..5ee3f44431dc37dfa3f3096335a215cc40228000 100644 --- a/sa/profiles/Qtech/QOS/get_interfaces.py +++ b/sa/profiles/Qtech/QOS/get_interfaces.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Qtech.QOS.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.core.ip import IPv4 diff --git a/sa/profiles/Qtech/QSW2500/get_interfaces.py b/sa/profiles/Qtech/QSW2500/get_interfaces.py index 7101c2ff35ab010a7b6930ebc6818104326ce7a8..1b1c4fe5d3a454aa072fd0666994212eb19875ec 100644 --- a/sa/profiles/Qtech/QSW2500/get_interfaces.py +++ b/sa/profiles/Qtech/QSW2500/get_interfaces.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.core.ip import IPv4 diff --git a/sa/profiles/Qtech/QSW2800/confdb/normalizer.py b/sa/profiles/Qtech/QSW2800/confdb/normalizer.py index 545ab7f022a17601574aefcc82aaf4d807285116..f976780afbd6c7b37797a71b82e0fa7ce24b8c04 100644 --- a/sa/profiles/Qtech/QSW2800/confdb/normalizer.py +++ b/sa/profiles/Qtech/QSW2800/confdb/normalizer.py @@ -8,7 +8,7 @@ # NOC modules from noc.core.confdb.normalizer.base import BaseNormalizer, match, ANY, REST -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list class Qtech2800Normalizer(BaseNormalizer): diff --git a/sa/profiles/Raisecom/ROS/get_interfaces.py b/sa/profiles/Raisecom/ROS/get_interfaces.py index a457a94fa5ba7031348624574c07d46174c4c829..5388441ed8011ae5b55d640d47ac06100a66248e 100644 --- a/sa/profiles/Raisecom/ROS/get_interfaces.py +++ b/sa/profiles/Raisecom/ROS/get_interfaces.py @@ -16,7 +16,7 @@ import six # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.core.ip import IPv4 diff --git a/sa/profiles/SKS/SKS/get_interfaces.py b/sa/profiles/SKS/SKS/get_interfaces.py index a9178b0b055fb8e0e8a95c182e438842ce71f91a..0a7c45ba413846063af2e177a0c1a39583cd0959 100644 --- a/sa/profiles/SKS/SKS/get_interfaces.py +++ b/sa/profiles/SKS/SKS/get_interfaces.py @@ -6,14 +6,13 @@ # See LICENSE for details # --------------------------------------------------------------------- - # Python modules import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/SKS/SKS/get_inventory.py b/sa/profiles/SKS/SKS/get_inventory.py index 193478b17b82678b97bd8e770c809442fd2e454a..ceabc378f32c93e3f09c1e4f392b7970297ad422 100644 --- a/sa/profiles/SKS/SKS/get_inventory.py +++ b/sa/profiles/SKS/SKS/get_inventory.py @@ -9,7 +9,7 @@ # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/SKS/SKS/get_lldp_neighbors.py b/sa/profiles/SKS/SKS/get_lldp_neighbors.py index a2ec9587a6251f5e9b5a03735aa2ade181d90917..8cd4e1475a5c0d242a8f22a1b533be4a4af75c95 100644 --- a/sa/profiles/SKS/SKS/get_lldp_neighbors.py +++ b/sa/profiles/SKS/SKS/get_lldp_neighbors.py @@ -6,7 +6,6 @@ # See LICENSE for details # --------------------------------------------------------------------- - # Python modules import re @@ -14,7 +13,7 @@ import re from noc.core.script.base import BaseScript from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors from noc.lib.validators import is_ipv4, is_ipv6, is_mac -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/SKS/SKS/get_version.py b/sa/profiles/SKS/SKS/get_version.py index ad79e49b80591a195a98216bbe89f9d2d522cf58..acf9bfdfcfbaa469a8aaa326683e6803d083af42 100644 --- a/sa/profiles/SKS/SKS/get_version.py +++ b/sa/profiles/SKS/SKS/get_version.py @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/SKS/SKS/get_vlans.py b/sa/profiles/SKS/SKS/get_vlans.py index 08c1526d28d5f3b5392363a405f1fa9e114b300b..84b1b1d97e75a0e679b86f8c71ea8d45ba5c0642 100644 --- a/sa/profiles/SKS/SKS/get_vlans.py +++ b/sa/profiles/SKS/SKS/get_vlans.py @@ -2,15 +2,17 @@ # --------------------------------------------------------------------- # SKS.SKS.get_vlans # --------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# Python modules import re + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetvlans import IGetVlans -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Supertel/K2X/set_switchport.py b/sa/profiles/Supertel/K2X/set_switchport.py index a0d204c1164b73869b11a1345035c47f9078da06..8fb2c8a701fcafc7094f0c819df3a811cb643a28 100644 --- a/sa/profiles/Supertel/K2X/set_switchport.py +++ b/sa/profiles/Supertel/K2X/set_switchport.py @@ -2,14 +2,14 @@ # --------------------------------------------------------------------- # Supertel.K2X.set_switchport # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.isetswitchport import ISetSwitchport -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges class Script(BaseScript): diff --git a/sa/profiles/TFortis/PSW/get_version.py b/sa/profiles/TFortis/PSW/get_version.py index 14095ad9e466044154b00a7356e0b3b5a8d54b16..3f9285fae944eb7b7a20aaf01cef6e7f63e22baf 100644 --- a/sa/profiles/TFortis/PSW/get_version.py +++ b/sa/profiles/TFortis/PSW/get_version.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # --------------------------------------------------------------------- -# Copyright (C) 2007-2016 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -10,7 +10,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import strip_html_tags +from noc.core.text import strip_html_tags class Script(BaseScript): diff --git a/sa/profiles/Upvel/UP/get_interfaces.py b/sa/profiles/Upvel/UP/get_interfaces.py index dfdd2ec48bc8abd71367f72682dabc5fb66cd1c8..6c3598213dc30268044503a54a9619b0f286e4ed 100644 --- a/sa/profiles/Upvel/UP/get_interfaces.py +++ b/sa/profiles/Upvel/UP/get_interfaces.py @@ -2,15 +2,17 @@ # --------------------------------------------------------------------- # Upvel.UP.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules +import re +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table -import re +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/Vitesse/VSC/get_interfaces.py b/sa/profiles/Vitesse/VSC/get_interfaces.py index 807fc1098c9e12bb40ad6a91667c9b6209facbbe..3fbdb6844a8f6ca91988ad12f98f3a2093985746 100644 --- a/sa/profiles/Vitesse/VSC/get_interfaces.py +++ b/sa/profiles/Vitesse/VSC/get_interfaces.py @@ -2,15 +2,17 @@ # --------------------------------------------------------------------- # Vitesse.VSC.get_interfaces # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- +# Python modules +import re +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces -from noc.lib.text import parse_table -import re +from noc.core.text import parse_table class Script(BaseScript): diff --git a/sa/profiles/ZTE/ZXDSL531/get_dot11_associations.py b/sa/profiles/ZTE/ZXDSL531/get_dot11_associations.py index 4a0a8b924a03ef2a65414beabe9c0c7674a74a96..f70beb38a18f8aaf4b1f040a4d2c358773707a65 100644 --- a/sa/profiles/ZTE/ZXDSL531/get_dot11_associations.py +++ b/sa/profiles/ZTE/ZXDSL531/get_dot11_associations.py @@ -1,14 +1,18 @@ # -*- coding: utf-8 -*- # --------------------------------------------------------------------- -# Copyright (C) 2007-2009 The NOC Project +# ZTE.ZXDSL531.get_dot11_associations +# --------------------------------------------------------------------- +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# Python modules +import re + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetdot11associations import IGetDot11Associations -from noc.lib.text import strip_html_tags -import re +from noc.core.text import strip_html_tags rx_mac = re.compile( "(?P[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2})" diff --git a/sa/profiles/ZTE/ZXDSL531/get_version.py b/sa/profiles/ZTE/ZXDSL531/get_version.py index dda99aecc39ad164c52dd6ac53a5dea7fcf07c80..bff38a5a0cc9837897a2ca68d08e28b7b650d91a 100644 --- a/sa/profiles/ZTE/ZXDSL531/get_version.py +++ b/sa/profiles/ZTE/ZXDSL531/get_version.py @@ -1,14 +1,18 @@ # -*- coding: utf-8 -*- # --------------------------------------------------------------------- -# Copyright (C) 2007-2009 The NOC Project +# ZTE.ZXDSL531.get_version +# --------------------------------------------------------------------- +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- -""" -""" + +# Python modules +import re + +# NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion -from noc.lib.text import strip_html_tags -import re +from noc.core.text import strip_html_tags rx_html_ver = re.compile(r"Firmware Version\s+\S+\s+(?P\S+)") diff --git a/sa/profiles/Zhone/Bitstorm/get_version.py b/sa/profiles/Zhone/Bitstorm/get_version.py index e17cc8bd5a30f95b6569d58575c371602300c6ce..dc2055fd8997aa43248abe04177ccd2158b02075 100644 --- a/sa/profiles/Zhone/Bitstorm/get_version.py +++ b/sa/profiles/Zhone/Bitstorm/get_version.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Zhone.Bitstorm.get_version # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -10,7 +10,7 @@ import re # NOC modules -from noc.lib.text import parse_table +from noc.core.text import parse_table from noc.core.script.base import BaseScript from noc.sa.interfaces.igetversion import IGetVersion diff --git a/sa/profiles/Zyxel/MSAN/get_inventory.py b/sa/profiles/Zyxel/MSAN/get_inventory.py index 07fbba7268add28a57b7b3964141d45e5bf524d8..c3cd81152aa44359f18a1aa10df770552d3152b5 100644 --- a/sa/profiles/Zyxel/MSAN/get_inventory.py +++ b/sa/profiles/Zyxel/MSAN/get_inventory.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Zyxel.MSAN.get_inventory # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -12,7 +12,7 @@ import re # NOC modules from noc.core.script.base import BaseScript from noc.sa.interfaces.igetinventory import IGetInventory -from noc.lib.text import parse_table +from noc.core.text import parse_table class Script(BaseScript): diff --git a/services/card/cards/managedobject.py b/services/card/cards/managedobject.py index 1bcc9b369c02e929503df9f8b4662f9d86fe15e3..354f7fc4d7517dde2eec9932010aa7abd13f3f94 100644 --- a/services/card/cards/managedobject.py +++ b/services/card/cards/managedobject.py @@ -31,7 +31,7 @@ from noc.inv.models.link import Link from noc.sa.models.service import Service from noc.inv.models.firmwarepolicy import FirmwarePolicy from noc.sa.models.servicesummary import ServiceSummary -from noc.lib.text import split_alnum, list_to_ranges +from noc.core.text import split_alnum, list_to_ranges from noc.maintenance.models.maintenance import Maintenance from noc.sa.models.useraccess import UserAccess from noc.core.pm.utils import get_interface_metrics, get_objects_metrics diff --git a/services/datasource/datasources/base.py b/services/datasource/datasources/base.py index acb44e7d64e825dcaddd817e3431d3e5c3d41765..45db525d7c1885c66d006378249a7056167d6737 100644 --- a/services/datasource/datasources/base.py +++ b/services/datasource/datasources/base.py @@ -13,7 +13,7 @@ import six from noc.main.models.datasourcecache import DataSourceCache from noc.core.perf import metrics from noc.config import config -from noc.lib.text import ch_escape +from noc.core.text import ch_escape class BaseDataSource(object): diff --git a/services/datastream/streams/managedobject.py b/services/datastream/streams/managedobject.py index 2e9ce855d01736d71f5f53640507306ea8802c80..4d23976cd640be873135d77826b607befaf4bd39 100644 --- a/services/datastream/streams/managedobject.py +++ b/services/datastream/streams/managedobject.py @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------- # managedobject datastream # ---------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- @@ -19,7 +19,7 @@ from noc.inv.models.interface import Interface from noc.inv.models.subinterface import SubInterface from noc.inv.models.link import Link from noc.inv.models.discoveryid import DiscoveryID -from noc.lib.text import split_alnum +from noc.core.text import split_alnum def qs(s): diff --git a/services/discovery/jobs/box/asset.py b/services/discovery/jobs/box/asset.py index bcf2ab1c3ab51e5f5fdb10b34659d96184d4078f..e5e2b9272573d7d0e09d68e4e52afd2b60d77a33 100644 --- a/services/discovery/jobs/box/asset.py +++ b/services/discovery/jobs/box/asset.py @@ -2,7 +2,7 @@ # --------------------------------------------------------------------- # Asset check # --------------------------------------------------------------------- -# Copyright (C) 2007-2017 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -22,7 +22,7 @@ from noc.inv.models.vendor import Vendor from noc.inv.models.unknownmodel import UnknownModel from noc.inv.models.modelmapping import ModelMapping from noc.inv.models.error import ConnectionError -from noc.lib.text import str_dict +from noc.core.text import str_dict class AssetCheck(DiscoveryCheck): diff --git a/services/discovery/jobs/box/interface.py b/services/discovery/jobs/box/interface.py index 9ce2ed334a12752dda036879cf6cc5c188bf0997..64462ba5991decbd65339ceb1bd28c215f2ed51c 100644 --- a/services/discovery/jobs/box/interface.py +++ b/services/discovery/jobs/box/interface.py @@ -13,7 +13,7 @@ from collections import defaultdict import six # NOC modules -from noc.lib.text import ranges_to_list +from noc.core.text import ranges_to_list from noc.services.discovery.jobs.base import PolicyDiscoveryCheck from noc.core.vpn import get_vpn_id from noc.core.service.rpc import RPCError diff --git a/services/discovery/jobs/box/suggestcli.py b/services/discovery/jobs/box/suggestcli.py index a5f5fd95b02e0a32817b751728e342ab55c11e41..043ff5a6c526e86c9bf83e0d54fa8ee1067ec93b 100644 --- a/services/discovery/jobs/box/suggestcli.py +++ b/services/discovery/jobs/box/suggestcli.py @@ -11,7 +11,7 @@ from noc.services.discovery.jobs.base import DiscoveryCheck from noc.core.service.client import open_sync_rpc from noc.core.service.error import RPCError from noc.core.script.scheme import SSH -from noc.lib.text import safe_shadow +from noc.core.text import safe_shadow class SuggestCLICheck(DiscoveryCheck): diff --git a/services/syslogcollector/service.py b/services/syslogcollector/service.py index f10976feb15c0a3a0623985e17a7cfe9810328d4..fd9f5e5cb70ecd39b6af541d8d0e607c9b5a0569 100755 --- a/services/syslogcollector/service.py +++ b/services/syslogcollector/service.py @@ -23,7 +23,7 @@ from noc.core.service.base import Service from noc.core.perf import metrics from noc.services.syslogcollector.syslogserver import SyslogServer from noc.services.syslogcollector.datastream import SysologDataStreamClient -from noc.lib.text import ch_escape +from noc.core.text import ch_escape SourceConfig = namedtuple( "SourceConfig", ["id", "addresses", "bi_id", "process_events", "archive_events"] diff --git a/services/web/apps/fm/reportlocalrules/views.py b/services/web/apps/fm/reportlocalrules/views.py index 01bb22bbe28e1452cbc29c4a93d4035a15ff45ef..1035e9307cd465b4c0d228ff8c9c043070831c07 100644 --- a/services/web/apps/fm/reportlocalrules/views.py +++ b/services/web/apps/fm/reportlocalrules/views.py @@ -12,7 +12,7 @@ from django.utils.html import escape # NOC modules from noc.lib.app.reportapplication import ReportApplication from noc.fm.models.eventclassificationrule import EventClassificationRule -from noc.lib.text import indent +from noc.core.text import indent from noc.core.translation import ugettext as _ from noc.core.collection.base import Collection diff --git a/services/web/apps/inv/interface/views.py b/services/web/apps/inv/interface/views.py index 61fa0b39381aa11001a4a486de506fc1987a7b3a..2a1fef8278073b64b0896509c50afd8ffae8a4a1 100644 --- a/services/web/apps/inv/interface/views.py +++ b/services/web/apps/inv/interface/views.py @@ -24,7 +24,7 @@ from noc.sa.interfaces.base import ( from noc.main.models.resourcestate import ResourceState from noc.project.models.project import Project from noc.vc.models.vcdomain import VCDomain -from noc.lib.text import split_alnum +from noc.core.text import split_alnum from noc.core.translation import ugettext as _ from noc.config import config diff --git a/services/web/apps/inv/map/views.py b/services/web/apps/inv/map/views.py index 0549f3519e8ab68c148b3369242595f14856efd3..cc44dc6e74d812001fab9889a504e5fc302d6f71 100644 --- a/services/web/apps/inv/map/views.py +++ b/services/web/apps/inv/map/views.py @@ -27,7 +27,7 @@ from noc.fm.models.activealarm import ActiveAlarm from noc.core.topology.segment import SegmentTopology from noc.inv.models.discoveryid import DiscoveryID from noc.maintenance.models.maintenance import Maintenance -from noc.lib.text import split_alnum +from noc.core.text import split_alnum from noc.core.pm.utils import get_interface_metrics from noc.sa.interfaces.base import ( ListOfParameter, diff --git a/services/web/apps/inv/reportifacestatus/views.py b/services/web/apps/inv/reportifacestatus/views.py index 3a2304993bf8abecc55f3fd5afc1fc356fd36b26..ce6dd30b9c6aac54a9c6fe363266a0c73a747a59 100644 --- a/services/web/apps/inv/reportifacestatus/views.py +++ b/services/web/apps/inv/reportifacestatus/views.py @@ -28,7 +28,7 @@ from noc.sa.models.administrativedomain import AdministrativeDomain from noc.sa.models.useraccess import UserAccess from noc.core.translation import ugettext as _ from noc.sa.interfaces.base import StringParameter -from noc.lib.text import list_to_ranges +from noc.core.text import list_to_ranges logger = logging.getLogger(__name__) diff --git a/services/web/apps/pm/ddash/dashboards/mo.py b/services/web/apps/pm/ddash/dashboards/mo.py index 9fdd24d31bc8037bf679f72f03666897ca1dcb85..23492fb7196b618673237148f3a6c611bf6bab38 100644 --- a/services/web/apps/pm/ddash/dashboards/mo.py +++ b/services/web/apps/pm/ddash/dashboards/mo.py @@ -19,7 +19,7 @@ from .base import BaseDashboard from noc.config import config from noc.inv.models.interface import Interface from noc.inv.models.subinterface import SubInterface -from noc.lib.text import split_alnum +from noc.core.text import split_alnum from noc.pm.models.metrictype import MetricType from noc.sa.models.managedobject import ManagedObject diff --git a/services/web/apps/sa/managedobject/views.py b/services/web/apps/sa/managedobject/views.py index f29ccd3e56a52eec6a0dfdc44222024e1860228d..3184fdb17e3d3577ddf56ee896eacf746cd3bf55 100644 --- a/services/web/apps/sa/managedobject/views.py +++ b/services/web/apps/sa/managedobject/views.py @@ -12,8 +12,6 @@ import zlib # Third-party modules from django.http import HttpResponse - -# Third-party modules import ujson from mongoengine.queryset import Q as MQ @@ -39,7 +37,7 @@ from noc.main.models.resourcestate import ResourceState from noc.project.models.project import Project from noc.vc.models.vcdomain import VCDomain from noc.sa.models.objectcapabilities import ObjectCapabilities -from noc.lib.text import split_alnum +from noc.core.text import split_alnum from noc.sa.interfaces.base import ( ListOfParameter, ModelParameter, diff --git a/tests/test_text.py b/tests/test_text.py index a5afe3b29edcdd148a0cd50df93dffc4e3e272e8..6ea154785c5460fea80e803b3f0b5b257c014a5a 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -2,15 +2,30 @@ # ---------------------------------------------------------------------- # noc.lib.text tests # ---------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2019 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- -# Thirt-party modules +# Third-party modules import pytest # NOC modules -from noc.lib.text import parse_table +from noc.core.text import ( + parse_table, + strip_html_tags, + xml_to_table, + list_to_ranges, + ranges_to_list, + replace_re_group, + indent, + split_alnum, + find_indented, + to_seconds, + format_table, + clean_number, + safe_shadow, + ch_escape, +) @pytest.mark.parametrize( @@ -248,3 +263,166 @@ te1/0/3 (1RY\t# GigabitEthernet1/ MBH_75_00020_1 B, R 1 ) def test_parse_table(value, kwargs, expected): assert parse_table(value, **kwargs) == expected + + +@pytest.mark.parametrize("expected", ["Title Body Text"]) +def test_strip_html_tags(expected): + html = """ + + + Title + + +

Body

+

Text

+ + + """ + out = strip_html_tags(html) + out = out.strip() + out = out.replace("\n", "") + assert out == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ( + [ + '1234' # noqa + ], + [{"a": "1", "b": "2"}, {"a": "3", "b": "4"}], + ) + ], +) +def test_xml_to_table(config, expected): + assert xml_to_table(str(config), "action", "row") == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ([], ""), + ([1], "1"), + ([1, 2], "1-2"), + ([1, 2, 3], "1-3"), + ([1, 2, 3, 5], "1-3,5"), + ([1, 2, 3, 5, 6, 7], "1-3,5-7"), + (range(1, 4001), "1-4000"), + ], +) +def test_list_to_ranges(config, expected): + assert list_to_ranges(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ("1", [1]), + ("1, 2", [1, 2]), + ("1, 10-12", [1, 10, 11, 12]), + ("1, 10-12, 15, 17-19", [1, 10, 11, 12, 15, 17, 18, 19]), + ], +) +def test_ranges_to_list(config, expected): + assert ranges_to_list(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ("nothing", "nothing"), + ("the (?Psimple) test", "the groupvalue test"), + ("the (?P nested (test)>)", "the groupvalue"), + ], +) +def test_replace_re_group(config, expected): + assert replace_re_group(config, "(?P", "groupvalue") == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ("", ""), + ( + "the quick brown fox\\njumped over an lazy dog\\nend", + " the quick brown fox\\njumped over an lazy dog\\nend", + ), + ], +) +def test_indent(config, expected): + assert indent(config, n=1) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ("Fa 0/1", ["Fa ", 0, "/", 1]), + ("Fa 0/1.15", ["Fa ", 0, "/", 1, ".", 15]), + ("ge-1/0/1", ["ge-", 1, "/", 0, "/", 1]), + ("ge-1/0/1.15", ["ge-", 1, "/", 0, "/", 1, ".", 15]), + ], +) +def test_split_alnum(config, expected): + assert split_alnum(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ( + "section0\nsection 1\n line 1-1\n line 1-2\n\n section 2\n line 2-1\n line 2-2", + ["section 1\n line 1-1\n line 1-2\n section 2\n line 2-1\n line 2-2"], + ) + ], +) +def test_find_indented(config, expected): + assert find_indented(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [("1h", 3600), ("1d", 86400), ("1w", 604800), ("1m", 2592000), ("1y", 31536000)], +) +def test_to_seconds(config, expected): + assert to_seconds(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ( + [["H1", "H2", "H3"], ["s1", "s2", "s3"], ["s1.1", "s2.1", "s3.1"]], + "H1 H2 H3 \n---- ---- ----\ns1 s2 s3 \ns1.1 s2.1 s3.1", + ) + ], +) +def test_format_table(config, expected): + assert format_table([0, 0, 0, 0, 0], config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [("12w34r5t6y7", "1234567"), (" 223ssSSSf*3", "2233"), ("(032HDWeg sda^@3f ", "0323")], +) +def test_clean_number(config, expected): + assert clean_number(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [(None, "None"), ("s", "******"), ("sssssss", "s******s"), ("1", "******"), ([1, 2], "******")], +) +def test_safe_shadow(config, expected): + assert safe_shadow(config) == expected + + +@pytest.mark.parametrize( + "config, expected", + [ + ("aaaa\nbbbb\nssssss\n", "aaaa\\\\nbbbb\\\\nssssss\\\\n"), + ("aaaa\nbbbb\nsss sss\n", "aaaa\\\\nbbbb\\\\nsss sss\\\\n"), + ], +) +def test_ch_escape(config, expected): + assert ch_escape(config) == expected