Beispiel #1
0
 def render(self):
     x = '<textarea name="%s"' % net.websafe(self.name)
     x += self.addatts()
     x += '>'
     if self.value is not None: x += net.websafe(self.value)
     x += '</textarea>'
     return x
Beispiel #2
0
 def render(self):
     x = '<input type="text" name="%s" size="%d" title="%s"' % (net.websafe(
         self.name), self.size, net.websafe(self.title))
     if self.val != None: x += ' value="%s"' % net.websafe(self.val)
     x += self.addatts()
     x += ' />'
     return x
Beispiel #3
0
 def render(self):
     x = '<textarea name="%s"' % net.websafe(self.name)
     x += self.addatts()
     x += '>'
     if self.value is not None: x += net.websafe(self.value)
     x += '</textarea>'
     return x
Beispiel #4
0
    def render(self):
	if (self.note or self.errors) and self.markwrong:
	    self.attrs['class'] = 'wrong'
        x = '<input type="password" name="%s"' % net.websafe(self.name)
        if self.value: x += ' value="%s"' % net.websafe(self.value)
        x += self.addatts()
        x += ' />'
        return x
 def render(self):
     x = '<input type="text" name="%s" size="%d" title="%s"' % (net.websafe(self.name),
                                                                self.size,
                                                                net.websafe(self.title))
     if self.val !=None: x += ' value="%s"' % net.websafe(self.val)
     x += self.addatts()
     x += ' />'
     return x
Beispiel #6
0
 def render(self):
     if (self.note or self.errors) and self.markwrong:
         self.attrs['class'] = 'wrong'
     x = '<input type="password" name="%s"' % net.websafe(self.name)
     if self.value: x += ' value="%s"' % net.websafe(self.value)
     x += self.addatts()
     x += ' />'
     return x
Beispiel #7
0
 def render(self):
     x = '<span>'
     for arg in self.args:
         if self.value == arg: select_p = ' checked="checked"'
         else: select_p = ''
         x += '<input type="radio" name="%s" value="%s"%s%s /> %s ' % (
             net.websafe(self.name), net.websafe(arg), select_p,
             self.addatts(), net.websafe(arg))
     return x + '</span>'
Beispiel #8
0
 def render_schema(self):
     out = '<thead>\n<tr>\n'
     if len(self.schema[0]) == 2:
         for i in self.schema:
             out += '<th class="">%s</th>\n' % (net.websafe(i[1]))
     elif len(self.schema[0]) == 3:
         for i in self.schema:
             out += '<th class="%s">%s</th>\n' % (i[2], net.websafe(i[1]))
     out += '</tr>\n</thead>\n'
     return out
 def render_schema(self):
     out = '<thead>\n<tr>\n'
     if len(self.schema[0]) == 2:
         for i in self.schema:
             out += '<th class="">%s</th>\n' % (net.websafe(i[1]))
     elif len(self.schema[0]) ==3:
         for i in self.schema:
             out += '<th class="%s">%s</th>\n' % (i[2],net.websafe(i[1]))
     out += '</tr>\n</thead>\n'
     return out
Beispiel #10
0
    def render(self):
        x = '<select name="%s"%s>\n' % (net.websafe(self.name), self.addatts())
        for arg in self.args:
            if type(arg) == tuple:
                value, desc= arg
            else:
                value, desc = arg, arg

            if self.value == value: select_p = ' selected="selected"'
            else: select_p = ''
            x += '  <option %s value="%s">%s</option>\n' % (select_p, net.websafe(value), net.websafe(desc))
        x += '</select>\n'
        return x
Beispiel #11
0
    def render(self):
        x = '<select name="%s"%s title="%s">\n' % (net.websafe(
            self.name), self.addatts(), net.websafe(self.title))
        for arg in self.args:
            if type(arg) == tuple:
                value, desc = arg
            else:
                value, desc = arg, arg

            if self.val == value: select_p = 'selected'
            else: select_p = ''
            x += '  <option %s>%s</option>\n' % (select_p, net.websafe(desc))
        x += '</select>\n'
        return x
Beispiel #12
0
    def render(self):
        x = '<select name="%s"%s title="%s">\n' % (net.websafe(self.name), self.addatts(), net.websafe(self.title))
        for arg in self.args:
            if type(arg) == tuple:
                value, desc = arg
            else:
                value, desc = arg, arg

            if self.val == value:
                select_p = "selected"
            else:
                select_p = ""
            x += "  <option %s>%s</option>\n" % (select_p, net.websafe(desc))
        x += "</select>\n"
        return x
Beispiel #13
0
 def render(self):
     x = '<span>'
     for arg in self.args:
         if self.value == arg: select_p = ' checked="checked"'
         else: select_p = ''
         x += '<input type="radio" name="%s" value="%s"%s%s /> %s ' % (net.websafe(self.name), net.websafe(arg), select_p, self.addatts(), net.websafe(arg))
     return x+'</span>'
    def render(self):
        out = ''

        for arg in self.args:
            out += '<div class="form-check">'
            out += '<label class="form-check-label">'

            if isinstance(arg, (tuple, list)):
                value, desc = arg
            else:
                value, desc = arg, arg

            attrs = self.attrs.copy()
            attrs['name'] = self.name
            attrs['id'] = self.name
            attrs['name'] = self.name
            attrs['type'] = 'radio'
            attrs['value'] = value

            if 'class' in attrs:
                attrs['class'] += ' form-check-input'
            else:
                attrs['class'] = 'form-check-input'

            if self.has_error():
                attrs['class'] += ' form-control-danger'

            if self.value == value:
                attrs['checked'] = 'checked'
            out += '<input %s> %s' % (attrs, net.websafe(desc))

            out += '</label></div>'

        return out
Beispiel #15
0
 def render_css(self):
     """
     modified original form render_css. add div for every input
     """
     out = [
         '<form method="%s" class="%s" action="%s" enctype="multipart/form-data">\n'
         % (self.method, self.formcss, self.callback),
         self.myformrendernote(self.form.note)
     ]
     # for upload reason, add enctype
     for i in self.form.inputs:
         if not i.is_hidden():
             iclass = "form-group"
             if i.note:
                 iclass += " has-error"
             out.append(
                 '<div class="%s">\n<label class="col-sm-3 control-label" for="%s">%s</label>\n'
                 % (iclass, i.id, net.websafe(i.description)))
         out.append(i.pre)
         out.append('<div class="col-sm-9">\n')
         out.append(i.render())
         out.append(self.myrendernote(i.id, i.note))
         out.append(i.post)
         if not i.is_hidden():
             out.append('</div>\n</div>\n')
         else:
             out.append('</div>\n')
     out.append('</form>')
     return ''.join(out)
Beispiel #16
0
    def render(self):
        out = ''
        out += self.rendernote(self.note)
        out += '<table class="form">\n'
        
        for input_ in self.inputs:
            html = utils.safeunicode(input_.pre) + input_.render() + \
                    self.rendernote(input_.note) + \
                    utils.safeunicode(input_.post)

            if input_.is_hidden():
                out += '    <tr style="display: none;">'
                out += '<th></th><td>%s</td></tr>\n' % (html)
            else: 
                out += '<tr class="blank_row"><td colspan="2"></td></tr>'
                out += '    <tr>' #start row
                
                #header on the left
                out += '    <td class="question"><label for="%s">' % \
                        input_.id 
                out += '%s</td>' % net.websafe(input_.description)

                #content on the right
                out += '<td><div style="float:left;">%s</div></td></tr>' % html
                out += '<tr class="blank_row_ruler"><td colspan="2"></td></tr>'

        out += '</table>'
        return out
 def render_css(self):
     """
     modified original form render_css. add div for every input
     """
     out = ['<form method="%s" class="%s" action="%s" enctype="multipart/form-data">\n' %
            (self.method,self.formcss, self.callback), self.myformrendernote(self.form.note)]
     # for upload reason, add enctype
     for i in self.form.inputs:
         if not i.is_hidden():
             iclass = "form-group"
             if i.note:
                 iclass += " has-error"
             out.append('<div class="%s">\n<label class="col-sm-3 control-label" for="%s">%s</label>\n' %
                        (iclass,i.id, net.websafe(i.description)))
         out.append(i.pre)
         out.append('<div class="col-sm-9">\n')
         out.append(i.render())
         out.append(self.myrendernote(i.id,i.note))
         out.append(i.post)
         if not i.is_hidden():
             out.append('</div>\n</div>\n')
         else:
             out.append('</div>\n')
     out.append('</form>')
     return ''.join(out)
    def render(self):
        out = ''
        out += self.rendernote(self.note)

        for i in self.inputs:
            if i.is_hidden():
                out += '%s\n' % i.render()
            else:
                out += i.group_start() + "\n"
                out += i.group_title() + "\n"
                if i.pre:
                    out += '<p class="form-text text-muted">%s</p>' % utils.safeunicode(
                        i.pre)
                out += i.render() + "\n"
                if i.note:
                    out += '<div class="form-control-feedback">%s</div>' % net.websafe(
                        i.note)
                if i.post and len(i.post) > 60:
                    out += '<p class="form-text text-muted">%s</p>' % utils.safeunicode(
                        i.post)
                elif i.post:
                    out += '<small class="text-muted">%s</small>' % utils.safeunicode(
                        i.post)
                out += i.group_end() + "\n"

        return out
Beispiel #19
0
def render(self):
		out = ''
		out += self.rendernote(self.note)
		out += '<div>'
		for i in self.inputs:
				html = i.render() + self.rendernote(i.note)
				out += '%s<div>%s\t%s</div>%s' % (utils.safeunicode(i.pre),
								net.websafe(i.description) ,
								html,
								utils.safeunicode(i.post)
								)
		out += "</div>\n"
		return out
Beispiel #20
0
def radioRender(self):
		x = ""
		for arg in self.args:
				if isinstance(arg, (tuple, list)):
						value, desc, class_ = arg
				else:
						value, desc = arg, arg
				attrs = self.attrs.copy()
				attrs['name'] = self.name
				attrs['type'] = 'radio'
				attrs['value'] = value
				if self.value == value:
						attrs['checked'] = 'checked'
				x += '<div class="%s"><input %s/> %s</div>' % (class_, attrs, net.websafe(desc))
		return x
    def render(self):
        attrs = self.attrs.copy()
        attrs['id'] = self.name
        attrs['name'] = self.name

        if 'class' in attrs:
            attrs['class'] += ' form-control'
        else:
            attrs['class'] = 'form-control'

        if self.has_error():
            attrs['class'] += ' form-control-danger'

        value = net.websafe(self.value or '')

        return '<textarea %s>%s</textarea>' % (attrs, value)
Beispiel #22
0
    def render(self):
        out = ""
        out += self.rendernote(self.note)

        for i in self.inputs:
            html = utils.safeunicode(i.pre) + i.render() + self.rendernote(i.note) + utils.safeunicode(i.post)
            if i.is_hidden():
                out += '    <tr style="display: none;"><th></th><td>%s</td></tr>\n' % (html)
            else:
                out += '    <div class="form-group"><label for="%s">%s</label>%s</div>\n' % (
                    i.id,
                    net.websafe(i.description),
                    html,
                )
        out += ""
        return out
 def render(self):
     out = ''
     for arg in self.args:
         out += '<div class="radio"><label>'
         if isinstance(arg, (tuple, list)):
             value, desc = arg
         else:
             value, desc = arg, arg
         attrs = self.attrs.copy()
         attrs['name'] = self.name
         attrs['type'] = 'radio'
         attrs['value'] = value
         if self.value == value:
             attrs['checked'] = 'checked'
         out += '<input %s> %s' % (attrs, net.websafe(desc))
         out += '</label></div>'
     return out
Beispiel #24
0
 def render(self):
     out = ''
     for arg in self.args:
         out += '<div class="radio"><label>'
         if isinstance(arg, (tuple, list)):
             value, desc = arg
         else:
             value, desc = arg, arg
         attrs = self.attrs.copy()
         attrs['name'] = self.name
         attrs['type'] = 'radio'
         attrs['value'] = value
         if self.value == value:
             attrs['checked'] = 'checked'
         out += '<input %s> %s' % (attrs, net.websafe(desc))
         out += '</label></div>'
     return out
    def render(self):
        attrs = self.attrs.copy()
        attrs['id'] = self.name
        attrs['name'] = self.name
        html = attrs.pop('html', None) or net.websafe(self.name)

        if 'class' in attrs:
            attrs['class'] += ' btn btn-primary'
        else:
            attrs['class'] = 'btn btn-primary'

        attrs['type'] = 'submit'

        if self.value is not None:
            attrs['value'] = self.value

        return '<button %s>%s</button>' % (attrs, html)
    def render(self):
        attrs = self.attrs.copy()
        attrs['type'] = 'checkbox'
        attrs['id'] = self.name
        attrs['name'] = self.name
        attrs['value'] = self.value

        if 'class' in attrs:
            attrs['class'] += ' form-check-input'
        else:
            attrs['class'] = 'form-check-input'

        if self.has_error():
            attrs['class'] += ' form-control-danger'

        if self.checked:
            attrs['checked'] = 'checked'
        return '<input %s> %s' % (attrs, net.websafe(self.description))
Beispiel #27
0
def recurse_over(ob, name, indent_level=0):
    ts = type_string(ob)
    if not ts in doc_these:
        return  #stos what shouldn't be docced getting docced
    if indent_level > 0 and ts == 'module':
        return  #Stops it getting into the stdlib
    if name in not_these_names:
        return  #Stops things we don't want getting docced

    indent = indent_level * indent_amount  #Indents nicely
    ds_indent = indent + (indent_amount / 2)
    if indent_level > 0: print indent_start % indent

    argstr = ''
    if ts.endswith(('function', 'method')):
        argstr = arg_string(ob)
    elif ts == 'classobj' or ts == 'type':
        if ts == 'classobj': ts = 'class'
        if hasattr(ob, '__init__'):
            if type_string(ob.__init__) == 'instancemethod':
                argstr = arg_string(ob.__init__)
        else:
            argstr = '(self)'
    if ts == 'instancemethod': ts = 'method'  #looks much nicer

    ds = inspect.getdoc(ob)
    if ds is None: ds = ''
    ds = markdown.Markdown(ds)

    mlink = '<a name="%s">' % name if ts == 'module' else ''
    mend = '</a>' if ts == 'module' else ''
    print ''.join(('<p>', ts_css(ts), item_start % ts, ' ', mlink, name,
                   websafe(argstr), mend, item_end, '<br />'))
    print ''.join((indent_start % ds_indent, ds, indent_end, '</p>'))
    #Although ''.join looks wierd, it's alot faster is string addition
    members = ''

    if hasattr(ob, '__all__'): members = ob.__all__
    else: members = [item for item in dir(ob) if not item.startswith('_')]

    if not 'im_class' in members:
        for name in members:
            recurse_over(getattr(ob, name), name, indent_level + 1)
    if indent_level > 0: print indent_end
Beispiel #28
0
    def render(self):
        #out = ''
        #out += self.rendernote(self.note)
        #out += '<table>\n'
        out = '<div id="form">'

        for i in self.inputs:
            html = (utils.safeunicode(i.pre) + i.render() +
                    self.rendernote(i.note) + utils.safeunicode(i.post))
            #if i.is_hidden():
            #    out += '    <tr style="display: none;"><th></th><td>%s</td></tr>\n' % (html)
            #else:
            #out += '    <tr><th><label for="%s">%s</label></th><td>%s</td></tr>\n' % (i.id, net.websafe(i.description), html)

            #to remove the label remove first %s and i.id !!
            out += ('<div id="%s_div"> %s %s</div>' %
                    (i.id, net.websafe(i.description), html))
        #out += "</table>"
        out += "</div>"
        return out
Beispiel #29
0
    def render(self):
        out = ''

        for arg in self.args:
            if isinstance(arg, (tuple, list)):
                value, desc = arg
            else:
                value, desc = arg, arg

            attrs = self.attrs.copy()
            attrs['name'] = self.name
            attrs['type'] = 'radio'
            attrs['value'] = value

            if self.value == value:
                attrs['checked'] = 'checked'

            out += '<input %s/> %s</br>' % (attrs, net.websafe(desc))

        return out
Beispiel #30
0
    def render(self):
    #out = ''
    #out += self.rendernote(self.note)
    #out += '<table>\n'
	    out = '<div id="form">'
	    
	    for i in self.inputs:
	        html = (utils.safeunicode(i.pre) + i.render() 
	        	+ self.rendernote(i.note) + utils.safeunicode(i.post))
	        #if i.is_hidden():
	        #    out += '    <tr style="display: none;"><th></th><td>%s</td></tr>\n' % (html)
	        #else:
	            #out += '    <tr><th><label for="%s">%s</label></th><td>%s</td></tr>\n' % (i.id, net.websafe(i.description), html)

	        #to remove the label remove first %s and i.id !!
	        out += ('<div id="%s_div"> %s %s</div>' % 
	        	(i.id, net.websafe(i.description), html))
	    #out += "</table>"
	    out += "</div>"
	    return out	
Beispiel #31
0
def recurse_over(ob, name, indent_level=0):
    ts = type_string(ob)    
    if not ts in doc_these: return #stos what shouldn't be docced getting docced
    if indent_level > 0 and ts == 'module': return #Stops it getting into the stdlib    
    if name in not_these_names: return #Stops things we don't want getting docced
    
    indent = indent_level * indent_amount #Indents nicely
    ds_indent = indent + (indent_amount / 2)
    if indent_level > 0: print(indent_start % indent)
    
    argstr = ''
    if ts.endswith(('function', 'method')):
        argstr = arg_string(ob)
    elif ts == 'classobj' or ts == 'type':
        if ts == 'classobj': ts = 'class'
        if hasattr(ob, '__init__'):
            if type_string(ob.__init__) == 'instancemethod':
                argstr = arg_string(ob.__init__)
        else:
            argstr = '(self)'
    if ts == 'instancemethod': ts = 'method' #looks much nicer
    
    ds = inspect.getdoc(ob)
    if ds is None: ds = ''
    ds = markdown.Markdown(ds)
    
    mlink = '<a name="%s">' % name if ts == 'module' else '' 
    mend = '</a>' if ts == 'module' else ''
    print(''.join(('<p>', ts_css(ts), item_start % ts, ' ', mlink, name,
                   websafe(argstr), mend, item_end, '<br />')))
    print(''.join((indent_start % ds_indent, ds, indent_end, '</p>')))
    #Although ''.join looks wierd, it's alot faster is string addition    
    members = ''
    
    if hasattr(ob, '__all__'): members = ob.__all__
    else: members = [item for item in dir(ob) if not item.startswith('_')] 
    
    if not 'im_class' in members:    
        for name in members:
            recurse_over(getattr(ob, name), name, indent_level + 1)
    if indent_level > 0: print(indent_end)
Beispiel #32
0
	def render(self):
		"""
		# with <div> 
		out = '<div id="form">'
		for i in self.inputs:
			html = (utils.safeunicode(i.pre) + i.render() 
			+ self.rendernote(i.note) + utils.safeunicode(i.post))
			out += ('<div id="%s_div"> %s %s</div>' % 
				(i.id, net.websafe(i.description), html))
		out += "</div>"
		return out
		"""
		#without <div>
		out = ''
		for i in self.inputs:
			html = (utils.safeunicode(i.pre) + i.render() 
			+ self.rendernote(i.note) + utils.safeunicode(i.post))
			out += ('%s %s' % (net.websafe(i.description), html))
		#out += "</div>"
		return out
		
    def render(self):
        attrs = self.attrs.copy()
        attrs['id'] = self.name
        attrs['name'] = self.name

        if 'class' in attrs:
            attrs['class'] += ' form-control'
        else:
            attrs['class'] = 'form-control'

        if self.has_error():
            attrs['class'] += ' form-control-danger'

        out = '<select %s>\n' % attrs

        for label, options in self.args:
            out += '  <optgroup label="%s">\n' % net.websafe(label)
            for arg in options:
                out += self._render_option(arg, indent='    ')
            out += '  </optgroup>\n'

        out += '</select>\n'

        return out
Beispiel #34
0
 def render(self):
     safename = net.websafe(self.name)
     x = '<button name="%s"%s>%s</button>' % (safename, self.addatts(), safename)
     return x
Beispiel #35
0
def recurse_over(ob, name, indent_level=0):
    ts = type_string(ob)
    if not ts in doc_these:
        return  # stos what shouldn't be docced getting docced
    if indent_level > 0 and ts == "module":
        return  # Stops it getting into the stdlib
    if name in not_these_names:
        return  # Stops things we don't want getting docced

    indent = indent_level * indent_amount  # Indents nicely
    ds_indent = indent + (indent_amount / 2)
    if indent_level > 0:
        print(indent_start % indent)

    argstr = ""
    if ts.endswith(("function", "method")):
        argstr = arg_string(ob)
    elif ts == "classobj" or ts == "type":
        if ts == "classobj":
            ts = "class"
        if hasattr(ob, "__init__"):
            if type_string(ob.__init__) == "instancemethod":
                argstr = arg_string(ob.__init__)
        else:
            argstr = "(self)"
    if ts == "instancemethod":
        ts = "method"  # looks much nicer

    ds = inspect.getdoc(ob)
    if ds is None:
        ds = ""
    ds = markdown.Markdown(ds)

    mlink = '<a name="%s">' % name if ts == "module" else ""
    mend = "</a>" if ts == "module" else ""
    print("".join((
        "<p>",
        ts_css(ts),
        item_start % ts,
        " ",
        mlink,
        name,
        websafe(argstr),
        mend,
        item_end,
        "<br />",
    )))
    print("".join((indent_start % ds_indent, ds, indent_end, "</p>")))
    # Although ''.join looks wierd, it's alot faster is string addition
    members = ""

    if hasattr(ob, "__all__"):
        members = ob.__all__
    else:
        members = [item for item in dir(ob) if not item.startswith("_")]

    if not "im_class" in members:
        for name in members:
            recurse_over(getattr(ob, name), name, indent_level + 1)
    if indent_level > 0:
        print(indent_end)
Beispiel #36
0
 def addatts(self):
     str = ""
     for (n, v) in self.attrs.items():
         str += ' %s="%s"' % (n, net.websafe(v))
     return str
Beispiel #37
0
 def addatts(self):
     str = ""
     for (n, v) in self.attrs.items():
         str += ' %s="%s"' % (n, net.websafe(v))
     return str
 def group_title(self):
     """show the title of this group of radio selections"""
     return '<legend>%s</legend>' % (net.websafe(self.description))
Beispiel #39
0
 def render(self):
     x = '<input type="hidden" name="%s"' % net.websafe(self.name)
     x += ' id="%s"' % net.websafe(self.name)
     if self.value: x += ' value="%s"' % net.websafe(self.value)
     x += ' />'
     return x
Beispiel #40
0
 def render(self):
     x = '<input type="file" name="%s"' % net.websafe(self.name)
     x += self.addatts()
     x += ' />'
     return x
 def rendernote(self, note):
     if note:
         return '<strong class="wrong">%s</strong>' % net.websafe(note)
     else:
         return ""
Beispiel #42
0
 def render(self):
     x = '<input name="%s" type="checkbox"' % net.websafe(self.name)
     if self.value: x += ' checked="checked"'
     x += self.addatts()
     x += ' />'
     return x
Beispiel #43
0
 def render(self):
     x = '<input name="%s" type="checkbox"' % net.websafe(self.name)
     if self.value: x += ' checked="checked"'
     x += self.addatts()
     x += ' />'
     return x
 def group_title(self):
     """show the title of this group of inputs"""
     return '<label id="%s">%s</label>' % (self.id,
                                           net.websafe(self.description))
Beispiel #45
0
 def render(self):
     safename = net.websafe(self.name)
     x = '<button name="%s"%s>%s</button>' % (safename, self.addatts(),
                                              safename)
     return x
Beispiel #46
0
 def render(self):
     x = '<input type="hidden" name="%s"' % net.websafe(self.name)
     x += ' id="%s"' % net.websafe(self.name)
     if self.value: x += ' value="%s"' % net.websafe(self.value)
     x += ' />'
     return x
Beispiel #47
0
 def render(self):
     x = '<input type="file" name="%s"' % net.websafe(self.name)
     x += self.addatts()
     x += ' />'
     return x