Module: check_mk
Branch: master
Commit: c3dd52bdef8ded129a6b260887b7896868426df2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3dd52bdef8ded…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 15 15:32:56 2015 +0100
Moved three functions from wato.py to watolib.py
---
web/htdocs/wato.py | 44 --------------------------------------------
web/htdocs/watolib.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 549e49b..2468fd3 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1021,50 +1021,6 @@ def mode_editfolder(phase, new):
html.end_form()
-def check_wato_foldername(htmlvarname, name, just_name = False):
- if not just_name and name in Folder.current().has_subfolder(name):
- raise MKUserError(htmlvarname, _("A folder with that name already
exists."))
-
- if not name:
- raise MKUserError(htmlvarname, _("Please specify a name."))
-
- if not re.match("^[-a-z0-9A-Z_]*$", name):
- raise MKUserError(htmlvarname, _("Invalid folder name. Only the characters
a-z, A-Z, 0-9, _ and - are allowed."))
-
-
-def create_wato_foldername(title, in_folder = None):
- if in_folder == None:
- in_folder = Folder.current()
-
- basename = convert_title_to_filename(title)
- c = 1
- name = basename
- while True:
- if not in_folder.has_subfolder(name):
- break
- c += 1
- name = "%s-%d" % (basename, c)
- return name
-
-
-def convert_title_to_filename(title):
- converted = ""
- for c in title.lower():
- if c == u'ä':
- converted += 'ae'
- elif c == u'ö':
- converted += 'oe'
- elif c == u'ü':
- converted += 'ue'
- elif c == u'ß':
- converted += 'ss'
- elif c in "abcdefghijklmnopqrstuvwxyz0123456789-_":
- converted += c
- else:
- converted += "_"
- return str(converted)
-
-
def ajax_set_foldertree():
config.save_user_file("foldertree", (html.var('topic'),
html.var('target')))
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index a3d022b..b9eb853 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -4030,6 +4030,51 @@ def must_be_in_contactgroups(cgspec):
( c, ", ".join(user_cgs)))
+def check_wato_foldername(htmlvarname, name, just_name = False):
+ if not just_name and name in Folder.current().has_subfolder(name):
+ raise MKUserError(htmlvarname, _("A folder with that name already
exists."))
+
+ if not name:
+ raise MKUserError(htmlvarname, _("Please specify a name."))
+
+ if not re.match("^[-a-z0-9A-Z_]*$", name):
+ raise MKUserError(htmlvarname, _("Invalid folder name. Only the characters
a-z, A-Z, 0-9, _ and - are allowed."))
+
+
+def create_wato_foldername(title, in_folder = None):
+ if in_folder == None:
+ in_folder = Folder.current()
+
+ basename = convert_title_to_filename(title)
+ c = 1
+ name = basename
+ while True:
+ if not in_folder.has_subfolder(name):
+ break
+ c += 1
+ name = "%s-%d" % (basename, c)
+ return name
+
+
+def convert_title_to_filename(title):
+ converted = ""
+ for c in title.lower():
+ if c == u'ä':
+ converted += 'ae'
+ elif c == u'ö':
+ converted += 'oe'
+ elif c == u'ü':
+ converted += 'ue'
+ elif c == u'ß':
+ converted += 'ss'
+ elif c in "abcdefghijklmnopqrstuvwxyz0123456789-_":
+ converted += c
+ else:
+ converted += "_"
+ return str(converted)
+
+
+
def rename_host_in_list(thelist, oldname, newname):
did_rename = False
for nr, element in enumerate(thelist):