code
stringlengths
1
1.72M
language
stringclasses
1 value
from core import convert, equals from codes import *
Python
#!/usr/bin/python import os from dcinstall import setup_py, debian, AbstractPackageInfo from dcinstall.version import get_revisions, get_changelog_core, save_last_revision class build(AbstractPackageInfo.build): sources_dir = os.path.realpath(os.path.dirname(__file__)) build_dir = sources_dir result_dir = ...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
VERSION="0.3.22"
Python
#!/usr/bin/env python2 # vim: set et sw=4: """agi This module contains functions and classes to implment AGI scripts in python. pyvr {'agi_callerid' : 'mars.putland.int', 'agi_channel' : 'IAX[kputland@kputland]/119', 'agi_context' : 'default', 'agi_dnid' : '666', 'agi_enhanced' : '0.0', 'agi_extension': '6...
Python
#!/usr/bin/env python # vim: set expandtab: """ Parse Asterisk configuration files. This module provides parsing functionality for asterisk config files. import asterisk.config import sys # load and parse the config file try: config = asterisk.config.Config('/etc/asterisk/extensions.conf') ex...
Python
""" pyst - A set of interfaces and libraries to allow programming of asterisk from python. The pyst project includes several python modules to assist in programming asterisk with python: agi - python wrapper for agi agitb - a module to assist in agi debugging, like cgitb config - a module for parsing asterisk ...
Python
"""More comprehensive traceback formatting for Python scripts. To enable this module, do: import asterisk.agitb, asterisk.agi asterisk.agitb.enable(display = False, logdir = '/var/log/asterisk/') agi = asterisk.agi.AGI() asterisk.agitb.enable(agi, False, '/var/log/asterisk') at the top of your scrip...
Python
#!/usr/bin/env python # vim: set expandtab shiftwidth=4: """ Python Interface for Asterisk Manager This module provides a Python API for interfacing with the asterisk manager. import asterisk.manager import sys def handle_shutdown(event, manager): print "Recieved shutdown event" manager.close()...
Python
#!/usr/bin/env python from asterisk.agi import * from conversions import conversions_list prefixes = ["9"] cel_code = "9" local_code = "11" def formatPhone(phone): parts = phone.split("-") if len(parts) == 1: return formatManualPhone(phone) else: return formatDialerPhone(parts) def forma...
Python
conversions_list = {"911":"15", "9220":"022015", "92202":"0220215", "9221":"022115", "92221":"0222115", "92223":"0222315", "92224":"0222415", "92225":"0222515", "92226":"0222615", "92227":"0222715", "92229":"0222915", "9223":"022315", "92241":"0224115", "92242":"0224215", "92243":"0224315", "92244":"0224415", "92245":"...
Python
#!/usr/bin/env python # CheckMentioned.py # Find all the properties used in SciTE source files and check if they # are mentioned in scite/doc/SciTEDoc.html. import os import string import stat srcRoot = "../../scite" srcDir = os.path.join(srcRoot, "src") docFileName = os.path.join(srcRoot, "doc", "SciTEDoc...
Python
#!/usr/bin/env python # RegenerateSource.py - implemented 2013 by Neil Hodgson neilh@scintilla.org # Released to the public domain. # Regenerate the SciTE source files that list all the lexers and all the # properties files. # Should be run whenever a new lexer is added or removed. # Requires Python 2.5 or late...
Python
#!/usr/bin/env python3 # CheckMentioned.py # Find all the symbols in scintilla/include/Scintilla.h and check if they # are mentioned in scintilla/doc/ScintillaDoc.html. import string uninteresting = { "SCINTILLA_H", "SCI_START", "SCI_LEXER_START", "SCI_OPTIONAL_START", # These archaic names are #defined to...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import with_statement import os, sys scintillaDirectory = os.path.join("..", "..", "scintilla") scintillaScriptsDirectory = os.path.join(scintillaDirectory, "scripts") sys.path.append(scintillaScriptsDirectory) import Face def cell(s): retu...
Python
#!/usr/bin/env python # makerpms.py # Copy files all over the place build RPMs and copy to top level directory import os import shutil srcRoot = "../../" rpmRoot = "/usr/src/redhat/SOURCES/" rpmBin = "/usr/src/redhat/RPMS/i386/" rpmSource = "/usr/src/redhat/SRPMS/" verFileName = srcRoot + "scintilla/versio...
Python
#! /usr/bin/env python # Produces a .api file for SciTE's identifier completion and calltip features. # invoke as # python tags2api.py tags >x.api # before running this program, create a tags file with # ctags --excmd=number --c-types=pcdgstu <header files> import fileinput import time # Definitions tha...
Python
#!/usr/bin/python # -*- coding: utf-8 -*- import sys from PySide.QtCore import * from PySide.QtGui import * import ScintillaConstants as sci sys.path.append("../..") from bin import ScintillaEditPy txtInit = "int main(int argc, char **argv) {\n" \ " // Start up the gnome\n" \ " gnome_init(...
Python
import distutils.sysconfig import getopt import glob import os import platform import shutil import subprocess import stat import sys sys.path.append(os.path.join("..", "ScintillaEdit")) import WidgetGen scintillaDirectory = "../.." scintillaScriptsDirectory = os.path.join(scintillaDirectory, "scripts")...
Python
#!/usr/bin/env python # WidgetGen.py - regenerate the ScintillaWidgetCpp.cpp and ScintillaWidgetCpp.h files # Check that API includes all gtkscintilla2 functions import sys import os import getopt scintillaDirectory = "../.." scintillaScriptsDirectory = os.path.join(scintillaDirectory, "scripts") sys.path.a...
Python
#!/usr/bin/env python # HFacer.py - regenerate the Scintilla.h and SciLexer.h files from the Scintilla.iface interface # definition file. # Implemented 2000 by Neil Hodgson neilh@scintilla.org # Requires Python 2.5 or later import sys import os import Face from FileGenerator import UpdateFile, Generate, Reg...
Python
# Script to generate CaseConvert.cxx from Python's Unicode data # Should be run rarely when a Python with a new version of Unicode data is available. # Should not be run with old versions of Python. # Current best approach divides case conversions into two cases: # simple symmetric and complex. # Simple symmetr...
Python
#!/usr/bin/env python # LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org # Released to the public domain. # Regenerate the Scintilla source files that list all the lexers. # Should be run whenever a new lexer is added or removed. # Requires Python 2.5 or later # Files are regenerated in place wi...
Python
# Script to generate CharacterCategory.cxx from Python's Unicode data # Should be run rarely when a Python with a new version of Unicode data is available. # Should not be run with old versions of Python. import codecs, os, platform, sys, unicodedata from FileGenerator import Regenerate def findCategories(fi...
Python
# Face.py - module for reading and parsing Scintilla.iface file # Implemented 2000 by Neil Hodgson neilh@scintilla.org # Released to the public domain. # Requires Python 2.5 or later def sanitiseLine(line): if line[-1:] == '\n': line = line[:-1] if line.find("##") != -1: line = line[:line.find("##")] lin...
Python
# ScintillaData.py - implemented 2013 by Neil Hodgson neilh@scintilla.org # Released to the public domain. # Common code used by Scintilla and SciTE for source file regeneration. # The ScintillaData object exposes information about Scintilla as properties: # Version properties # version # versionDotted ...
Python
#!/usr/bin/env python # LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org # Released to the public domain. # Regenerate the Scintilla and SciTE source files that list # all the lexers and all the properties files. # Should be run whenever a new lexer is added or removed. # Requires Python 2.4 or ...
Python
# -*- coding: utf-8 -*- from __future__ import with_statement import io, os, sys, unittest if sys.platform == "win32": import XiteWin as Xite else: import XiteQt as Xite keywordsHTML = [ b"b body content head href html link meta " b"name rel script strong title type xmlns", b"function", b"sub" ] ...
Python
# List many windows message numbers msgs = { "WM_ACTIVATE":6, "WM_ACTIVATEAPP":28, "WM_CAPTURECHANGED":533, "WM_CHAR":258, "WM_CLOSE":16, "WM_CREATE":1, "WM_COMMAND":273, "WM_DESTROY":2, "WM_ENTERSIZEMOVE":561, "WM_ERASEBKGND":20, "WM_EXITSIZEMOVE":562, "WM_GETMINMAXINFO":36, "WM_GETTEXT":13, "WM_IME_S...
Python
# -*- coding: utf-8 -*- from __future__ import with_statement from __future__ import unicode_literals import codecs, ctypes, os, sys, unittest if sys.platform == "win32": import XiteWin as Xite else: import XiteQt as Xite class TestSimple(unittest.TestCase): def setUp(self): self.xite = Xite.xi...
Python
# -*- coding: utf-8 -*- from __future__ import with_statement from __future__ import unicode_literals import os, sys, unittest import ctypes from ctypes import wintypes from ctypes import c_int, c_ulong, c_char_p, c_wchar_p, c_ushort, c_uint, c_long from ctypes.wintypes import HWND, WPARAM, LPARAM, HANDLE,...
Python
# Convert all punctuation characters except '_', '*', and '.' into spaces. def depunctuate(s): '''A docstring''' """Docstring 2""" d = "" for ch in s: if ch in 'abcde': d = d + ch else: d = d + " " return d
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals import ctypes, os, sys from ctypes import c_int, c_ulong, c_char_p, c_wchar_p, c_ushort, c_uint, c_long class TEXTRANGE(ctypes.Structure): _fields_= (\ ('cpMin', c_long), ('cpMax', c_long), ('lpstrText', ctypes.POINTER(ctypes.c_char)...
Python
# -*- coding: utf-8 -*- from __future__ import with_statement from __future__ import unicode_literals import os, string, sys, time, unittest if sys.platform == "win32": import XiteWin as Xite else: import XiteQt as Xite class TestPerformance(unittest.TestCase): def setUp(self): self.xite = Xite...
Python
# -*- coding: utf-8 -*- import ctypes, os, sys, unittest from PySide.QtCore import * from PySide.QtGui import * import ScintillaCallable sys.path.append("..") from bin import ScintillaEditPy scintillaDirectory = ".." scintillaIncludeDirectory = os.path.join(scintillaDirectory, "include") scintillaScr...
Python
# -*- coding: utf-8 -*- import XiteWin if __name__ == "__main__": XiteWin.main("")
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals """ Define the menu structure used by the Pentacle applications """ MenuStructure = [ ["&File", [ ["&New", "<control>N"], ["&Open...", "<control>O"], ["&Save", "<control>S"], ["Save &As...", "<control><shift>S"], ["Test", ""], ...
Python
from sys import argv First = {} Follow = {} nterminais = {} NT_SEM_SIGMA = {} NULO = set([]) SIGMA = '%' SEPARA_PROD = '@' SEPARA_ALT = '|' FIM_ENTRADA = '$' COD_NT = {} COD_T = {} COD_R = {} REGRA = {} def first(cadeia, i): global First, nterminais, SIGMA if cadeia == []: return set([]) N = len(c...
Python
#!/usr/bin/python import glob PRE = """ <PROGRAM> @ PROGRAM id <COMMAND> ENDPROGRAM id <COMMAND> @ <CONTROLE_INTRINSC> <COMMAND> | % <CONTROLE_INTRINSC> @ <IF> | <DO> | <FUNC_INTR> | <READ> | <WRITE> <IF> @ IF ( id ) <COMMAND> ENDIF <FUNC_INTRINS> @ SQRT ( token_LitInteger ) | POW ( token_LitInteger, token_LitInteger...
Python
#!/usr/bin/python import glob PRE = """ <PROGRAM> @ PROGRAM id <COMMAND> ENDPROGRAM id <COMMAND> @ <CONTROLE_INTRINSC> <COMMAND> | % <CONTROLE_INTRINSC> @ <IF> | <DO> | <FUNC_INTR> | <READ> | <WRITE> <IF> @ IF ( id ) <COMMAND> ENDIF <FUNC_INTRINS> @ SQRT ( token_LitInteger ) | POW ( token_LitInteger, token_LitInteger...
Python
with open("res.t", "r") as f: out = open("res_cons.txt", "w") for l in f: if l != None: first, second = l.split() out.write("{0} {0}\n".format(first,first))
Python
from twisted.application import internet, service from nevow import appserver from forms.examples import main application = service.Application('examples') service = internet.TCPServer(8000, main.makeSite(application)) service.setServiceParent(application)
Python
from setuptools import setup, find_packages import forms setup( name='forms', version=forms.version, description='HTML forms framework for Nevow', author='Matt Goodall', author_email='matt@pollenation.net', packages=find_packages(), package_data={ 'forms': ['forms.css', 'html/*', '...
Python
from datetime import date, time from twisted.application import internet, service from nevow import appserver, compy, loaders, rend, static, tags as T import forms import os from shutil import copyfileobj import mimetypes, datetime from forms import iforms, htmleditor, converters from fileresource import fileResource ...
Python
import os from shutil import copyfileobj FILESTORE_DIR='assets' FILESTORE_URL='webassets' class fileResource: def getUrlForFile(self, id): if id: return os.path.join(FILESTORE_URL, id) else: return None def storeFile( self, source, name ): id = name ...
Python
""" Form types. """ try: import decimal haveDecimal = True except ImportError: haveDecimal = False from zope.interface import implements from forms import iforms, validation class Type(object): implements( iforms.IType ) # Name of the instance name = None # Value to use if no value ent...
Python
""" Form implementation and high-level renderers. """ from zope.interface import Interface from twisted.internet import defer from twisted.python.components import registerAdapter from nevow import appserver, context, loaders, inevow, tags as T, url from nevow.util import getPOSTCharset from forms import iforms, util,...
Python
from nevow import tags as T, util from forms import iforms from zope.interface import implements tinyMCEGlue = T.xml(""" <!-- tinyMCE --> <script language="javascript" type="text/javascript" src="/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ ...
Python
from nevow import appserver, rend from forms.form import FormsResourceBehaviour class FormPage(rend.Page): """ Base class for pages that contain a Form. XXX This really, really needs to turn into a ComponentPage that iterates a bunch of component behaviours looking for something that succeeded. ...
Python
import tempfile import mimetypes import re import os from shutil import copyfileobj from exceptions import IOError, OSError class ResourceManagerException( Exception ): def __init__( self, *args, **kwds ): super( ResourceManagerException, self ).__init__( *args, **kwds ) class ResourceManager( object ): ...
Python
""" ReST text area widget. """ from nevow import inevow, loaders, rend, tags as T from forms import iforms, widget from forms.util import keytocssid from forms.form import widgetResourceURLFromContext class ReSTTextArea(widget.TextArea): """ A large text entry area that accepts ReST and previews it as HTML ...
Python
from zope.interface import implements from nevow import tags as T from forms import iforms from forms.util import keytocssid _UNSET = object() class MultichoiceBase(object): """ A base class for widgets that provide the UI to select one or more items from a list. Based on ChoiceBase options: ...
Python
"""Adapters for converting to and from a type's value according to an IConvertible protocol. """ from datetime import date, time try: import decimal haveDecimal = True except ImportError: haveDecimal = False from forms import iforms, validation from zope.interface import implements class _Adapter(object)...
Python
import re from zope.interface import implements from nevow import inevow from forms import iforms _IDENTIFIER_REGEX = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$') def titleFromName(name): def _(): it = iter(name) last = None while 1: ch = it.next() if ch == '_': ...
Python
""" Widgets are small components that render form fields for inputing data in a certain format. """ import itertools from nevow import inevow, loaders, tags as T, util, url, static, rend from nevow.i18n import _ from forms import converters, iforms, validation from forms.util import keytocssid from forms.form import w...
Python
import re from zope.interface import implements from forms import iforms class FormsError(Exception): """ Base class for all Forms errors. A single string, message, is accepted and stored as an attribute. The message is not passed on to the Exception base class because it doesn't seem to be a...
Python
from nevow import url import forms from forms.examples import main class ActionButtonsPage(main.FormExamplePage): title = 'Action Button' description = 'Example of non-validating button, buttons with non-default labels, etc' def form_example(self, ctx): form = forms.Form() form.addFie...
Python
import forms from forms.examples import main # Let the examples run if docutils is not installed try: import docutils except ImportError: import warnings warnings.warn("docutils is not installed") docutilsAvailable = False else: docutilsAvailable = True if docutilsAvailable: from docutils.wr...
Python
from zope.interface import implements import forms from forms import iforms from forms.examples import main # A not-too-good regex for matching an IP address. IP_ADDRESS_PATTERN = '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$' class ValidatorFormPage(main.FormExamplePage): title = 'Custom form validation' descri...
Python
import forms from forms.examples import main class SimpleFormPage(main.FormExamplePage): title = 'Simple Form' description = 'Probably the simplest form possible.' def form_example(self, ctx): form = forms.Form() form.addField('aString', forms.String()) form.addAction(self...
Python
try: import decimal haveDecimal = True except ImportError: haveDecimal = False import forms from forms.examples import main class TypesFormPage(main.FormExamplePage): title = 'Form Types' description = 'Example of using different typed fields.' def form_example(self, ctx): form = form...
Python
from datetime import date import forms from forms.examples import main class MissingFormPage(main.FormExamplePage): title = 'Missing Values' description = 'Providing default values when missing' def form_example(self, ctx): form = forms.Form() form.addField('aString', forms.String(mis...
Python
import forms from forms.examples import main class FileUploadFormPage(main.FormExamplePage): title = 'File Upload' description = 'Uploading a file' def form_example(self, ctx): form = forms.Form() form.addField('file', forms.File()) form.addAction(self.submitted) retur...
Python
import pkg_resources from zope.interface import implements from twisted.python import reflect from nevow import appserver, inevow, loaders, rend, static, tags as T, url import forms DOCTYPE = T.xml('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">') CHARSET ...
Python
import forms from forms.examples import main class SmartUploadFormPage(main.FormExamplePage): title = 'Smart File Upload' description = 'Smart uploading of files where the file is "carried across" when the validation fails' def form_example(self, ctx): form = forms.Form() form.addFiel...
Python
from datetime import datetime import forms from forms.examples import main class PrepopulateFormPage(main.FormExamplePage): title = 'Prepopulate' description = 'Example of prepopulating form fields' def form_example(self, ctx): form = forms.Form() form.addField('aString', forms.String...
Python
import forms from forms.examples import main class DatesTimesFormPage(main.FormExamplePage): title = 'Dates' description = 'Date entry examples' def form_example(self, ctx): form = forms.Form() form.addField('isoFormatDate', forms.Date(), forms.TextInput) form.addField('monthF...
Python
from twisted.internet import defer from datetime import date import forms from forms.examples import main # A boring list of (value, label) pairs. strings = [ ('foo', 'Foo'), ('bar', 'Bar'), ] # A list of dates with meaningful names. dates = [ (date(2005, 01, 01), 'New Year Day'), (date(2005, 11, ...
Python
import forms from forms.examples import main class NoFieldsFormPage(main.FormExamplePage): title = 'Form With no Fields' description = 'A form with no fields, just button(s). (Just to prove ' \ 'it works.)' def form_example(self, ctx): form = forms.Form() form.addActio...
Python
import forms from forms.examples import main class RequiredFormPage(main.FormExamplePage): title = 'Required Fields' description = 'Demonstration of required fields' def form_example(self, ctx): form = forms.Form() form.addField('name', forms.String(required=True)) form.addField('...
Python
"""A package (for Nevow) for defining the schema, validation and rendering of HTML forms. """ version_info = (0, 8, 0) version = '.'.join([str(i) for i in version_info]) from nevow import static from forms.types import * from forms.validation import * from forms.widget import * from forms.widgets.restwidget import ...
Python
from zope.interface import Interface class IType(Interface): def validate(self, value): pass class IStructure(Interface): pass class IWidget(Interface): def render(self, ctx, key, args, errors): pass def renderImmutable(self, ctx, key, args, errors): pass def process...
Python
from twisted.application import internet, service from nevow import appserver from forms.examples import main application = service.Application('examples') service = internet.TCPServer(8000, main.makeSite(application)) service.setServiceParent(application)
Python
from setuptools import setup, find_packages import forms setup( name='forms', version=forms.version, description='HTML forms framework for Nevow', author='Matt Goodall', author_email='matt@pollenation.net', packages=find_packages(), package_data={ 'forms': ['forms.css'], } ...
Python
from datetime import date, time from twisted.application import internet, service from nevow import appserver, compy, loaders, rend, static, tags as T import forms import os from shutil import copyfileobj import mimetypes, datetime from forms import iforms, htmleditor, converters from fileresource import fileResource ...
Python
import os from shutil import copyfileobj FILESTORE_DIR='assets' FILESTORE_URL='webassets' class fileResource: def getUrlForFile(self, id): if id: return os.path.join(FILESTORE_URL, id) else: return None def storeFile( self, source, name ): id = name ...
Python
""" Form types. """ from forms import iforms, validation from zope.interface import implements class Type(object): implements( iforms.IType ) # Name of the instance name = None # Instance is required required = False # Value to use if no value entered missing = None # Instance canno...
Python
""" Form implementation and high-level renderers. """ from twisted.internet import defer from nevow import context, loaders, inevow, tags as T, url from nevow.compy import registerAdapter, Interface from forms import iforms, util, validation from resourcemanager import ResourceManager from zope.interface import implem...
Python
from nevow import tags as T, util from forms import iforms from zope.interface import implements tinyMCEGlue = T.xml(""" <!-- tinyMCE --> <script language="javascript" type="text/javascript" src="/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ ...
Python
import tempfile import mimetypes import re import os from shutil import copyfileobj from exceptions import IOError, OSError class ResourceManagerException( Exception ): def __init__( self, *args, **kwds ): super( ResourceManagerException, self ).__init__( *args, **kwds ) class ResourceManager( object ): ...
Python
"""Adapters for converting to and from a type's value according to an IConvertible protocol. """ from datetime import date, time from nevow.compy import Adapter from forms import iforms, validation from zope.interface import implements class NullConverter(Adapter): implements( iforms.IStringConvertible ) ...
Python
from forms import iforms from zope.interface import implements def titleFromName(name): def _(): it = iter(name) last = None while 1: ch = it.next() if ch == '_': if last != '_': yield ' ' elif last in (None,'_'): ...
Python
""" Widgets are small components that render form fields for inputing data in a certain format. """ import itertools from nevow import inevow, tags as T, util, url, static from forms import converters, iforms, validation from forms.util import keytocssid from forms.form import formWidgetResource from zope.interface im...
Python
import re from zope.interface import implements from forms import iforms class FormError(Exception): pass class FieldError(Exception): def __init__(self, message, fieldName=None): Exception.__init__(self, message) self.message = message self.fieldName = fieldName cl...
Python
import forms title = 'Dates' description = 'Date entry examples' def makeForm(ctx): form = forms.Form() form.addField('isoFormat', forms.Date(), forms.TextInput) form.addField('monthFirst', forms.Date(), forms.DatePartsInput) form.addField('dayFirst', forms.Date(), forms.widgetFactory(forms.DatePartsI...
Python
import forms title = 'Simple Form' description = 'Probably the simplest form possible.' def makeForm(ctx): form = forms.Form() form.addField('aString', forms.String()) form.addAction(formSubmitted) return form def formSubmitted(ctx, form, data): print form, data
Python
import forms title = 'Form Types' description = 'Example of using different typed fields.' def makeForm(ctx): form = forms.Form() form.addField('aString', forms.String()) form.addField('aInteger', forms.Integer()) form.addField('aFloat', forms.Float()) form.addField('aBoolean', forms.Boolean()) ...
Python
from datetime import date import forms title = 'Missing Values' description = 'Providing default values when missing' def makeForm(ctx): form = forms.Form() form.addField('aString', forms.String(missing='<nothing>')) form.addField('aDate', forms.Date(missing=date(2005, 8, 1))) form.addAction(formSubmi...
Python
import forms title = 'File Upload' description = 'Uploading a file' def makeForm(ctx): form = forms.Form() form.addField('file', forms.File()) form.addAction(formSubmitted) return form def formSubmitted(ctx, form, data): print form, data
Python
import pkg_resources from twisted.python import reflect from nevow import appserver, loaders, rend, static, tags as T, url import forms DOCTYPE = T.xml('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">') CHARSET = T.xml('<meta http-equiv="content-type" conte...
Python
import forms title = 'Smart File Upload' description = 'Smart uploading of files where the file is "carried across" when the validation fails' def makeForm(ctx): form = forms.Form() form.addField('required', forms.String(required=True)) form.addField('file', forms.File(), forms.FileUploadWidget) form....
Python
from datetime import datetime import forms title = 'Prepopulate' description = 'Example of prepopulating form fields' def makeForm(ctx): form = forms.Form() form.addField('aString', forms.String()) form.addField('aTime', forms.Time()) form.addAction(formSubmitted) form.data = { 'aTime': da...
Python
from twisted.internet import defer from datetime import date import forms title = 'Selection widgets' description = 'Example of the various selection widgets' def makeForm(ctx): form = forms.Form() form.addField('required', forms.String(required=True)) form.addField('oneString', forms.String(), forms.widg...
Python
import forms title = 'Required Fields' description = 'Demonstration of required fields' def makeForm(ctx): form = forms.Form() form.addField('name', forms.String(required=True)) form.addField('age', forms.Integer()) form.addAction(formSubmitted) return form def formSubmitted(ctx, form, data): ...
Python
"""A package (for Nevow) for defining the schema, validation and rendering of HTML forms. """ version_info = (0, 2, 3) version = '.'.join([str(i) for i in version_info]) from nevow import static from forms.types import * from forms.validation import * from forms.widget import * from forms.form import Form, Resourc...
Python
from nevow.compy import Interface class IType(Interface): def validate(self, value): pass class IStructure(Interface): pass class IWidget(Interface): def render(self, ctx, key, args, errors): pass def renderImmutable(self, ctx, key, args, errors): ...
Python
""" Form types. """ try: import decimal haveDecimal = True except ImportError: haveDecimal = False from zope.interface import implements from formal import iformal, validation class Type(object): implements( iformal.IType ) # Name of the instance name = None # Value to use if no value ...
Python
""" Form implementation and high-level renderers. """ from zope.interface import Interface from twisted.internet import defer from twisted.python.components import registerAdapter from nevow import appserver, context, loaders, inevow, rend, tags as T, url from nevow.util import getPOSTCharset from formal import iforma...
Python
import warnings warnings.warn( "The htmleditor module is deprecated. To use an HTML editor with " \ "formal, render your field as a formal.TextArea and use JavaScript " \ "to turn the textarea into a HTML editor.", DeprecationWarning, stacklevel=2) from nevow import tags as T, ...
Python
from nevow import appserver, rend from formal.form import FormsResourceBehaviour class FormPage(rend.Page): """ Base class for pages that contain a Form. XXX This really, really needs to turn into a ComponentPage that iterates a bunch of component behaviours looking for something that succeeded. ...
Python