Beispiel #1
0
class NewFormForm(Schema):
    """NewFormForm is a Schema for validating the data entered at the Add Form
    page.
    
    """

    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]
    transcription = UnicodeString(
        not_empty=True, messages={'empty': 'Please enter a transcription.'})
    phoneticTranscription = UnicodeString()
    narrowPhoneticTranscription = UnicodeString()
    morphemeBreak = UnicodeString()
    grammaticality = UnicodeString()
    morphemeGloss = UnicodeString()
    glosses = FirstGlossNotEmpty()
    comments = UnicodeString()
    speakerComments = UnicodeString()
    context = UnicodeString()
    elicitationMethod = UnicodeString()
    keywords = ForEach(Keyword())
    syntacticCategory = UnicodeString()
    speaker = UnicodeString()
    elicitor = UnicodeString()
    verifier = UnicodeString()
    source = UnicodeString()
    dateElicited = DateConverter(month_style='mm/dd/yyyy')
Beispiel #2
0
class SearchFileForm(Schema):
    """SearchFile is a Schema for validating the search terms entered at the Search Files page."""
    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]
    searchTerm1 = UnicodeString()
    searchType1 = UnicodeString()
    searchLocation1 = UnicodeString()
    searchTerm2 = UnicodeString()
    searchType2 = UnicodeString()
    searchLocation2 = UnicodeString()
    andOrNot = UnicodeString()
    restrictors = ForEach(RestrictorStruct())
    dateRestrictors = ForEach(DateRestrictorStruct())
    integerRestrictors = ForEach(IntegerRestrictorStruct())
    orderByColumn = UnicodeString()
    orderByDirection = UnicodeString()
Beispiel #3
0
class PersonalSchema(Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]

    firstname = validators.UnicodeString(not_empty=True, strip=True)
    surname = validators.UnicodeString(not_empty=True, strip=True)
    headline = validators.UnicodeString(strip=True)
    company_name = validators.UnicodeString(strip=True)
    address = validators.UnicodeString(strip=True)
    mobile = validators.UnicodeString(strip=True)
    phone = validators.UnicodeString(strip=True)
    #websites = ForEach(WebVal())
    fb = validators.UnicodeString()
    tw = validators.UnicodeString()
    linkedin = validators.UnicodeString()
    user_type_id = validators.Int(not_empty=True)
    state_id = validators.Int(not_empty=True)
    city = validators.UnicodeString(not_empty=True, strip=True)
    prefix = validators.UnicodeString(required=True)
Beispiel #4
0
class AlterSettingsForm(Schema):
    """AlterSettingsForm is a Schema for validating the data entered at the
    system settings page.

    """

    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [variabledecode.NestedVariables()]

    OLName = UnicodeString()
    OLId = UnicodeString()

    MLName = UnicodeString()
    MLId = UnicodeString()
    MLOrthography = UnicodeString()

    headerImageName = UnicodeString()
    colorsCSS = UnicodeString()

    orthographyOptions = [u'Orthography %s' % unicode(i) for i \
                          in range(1,6)]
    storageOrthography = OneOf(orthographyOptions)
    defaultInputOrthography = UnicodeString()
    defaultOutputOrthography = UnicodeString()

    objectLanguageOrthography1Name = UnicodeString()
    objectLanguageOrthography1 = UnicodeString()
    OLO1Lowercase = StringBoolean(if_missing=False)
    OLO1InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography2Name = UnicodeString()
    objectLanguageOrthography2 = UnicodeString()
    OLO2Lowercase = StringBoolean(if_missing=False)
    OLO2InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography3Name = UnicodeString()
    objectLanguageOrthography3 = UnicodeString()
    OLO3Lowercase = StringBoolean(if_missing=False)
    OLO3InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography4Name = UnicodeString()
    objectLanguageOrthography4 = UnicodeString()
    OLO4Lowercase = StringBoolean(if_missing=False)
    OLO4InitialGlottalStops = StringBoolean(if_missing=False)

    objectLanguageOrthography5Name = UnicodeString()
    objectLanguageOrthography5 = UnicodeString()
    OLO5Lowercase = StringBoolean(if_missing=False)
    OLO5InitialGlottalStops = StringBoolean(if_missing=False)

    morphemeBreakIsObjectLanguageString = UnicodeString()

    unrestrictedUsers = ForEach(UnrestrictedUser())

    orthographicValidation = OneOf([u'None', u'Warning', u'Error'])
    narrPhonInventory = UnicodeString()
    narrPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    broadPhonInventory = UnicodeString()
    broadPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    morphPhonInventory = UnicodeString()
    morphDelimiters = UnicodeString()
    morphPhonValidation = OneOf([u'None', u'Warning', u'Error'])
    punctuation = UnicodeString()
    grammaticalities = UnicodeString()
Beispiel #5
0
class Chapman(object):
    """Usage:
            chapmand <config> [options]

    Options:
      -h --help                 show this help message and exit
      -c,--concurrency THREADS  number of threads to run [default: 1]
      -d,--debug                drop into a debugger on task errors?
      -n,--name NAME            override the name of the worker
    """
    settings_schema = fes.Schema(
        pre_validators=[fevd.NestedVariables()],
        name=fev.String(),
        queues=fef.ForEach(if_missing=['chapman']),
        path=fev.String(),
        sleep_ms=fev.Int())

    def __init__(self, name, path, queues, sleep_ms):
        self.name = '{}-{}'.format(name, base64.urlsafe_b64encode(os.urandom(6)))
        self.path = path
        self.queues = queues
        self.sleep_ms = sleep_ms

    @classmethod
    def script(cls):
        args = docopt(cls.__doc__)
        config = args['<config>']
        if '#' in config:
            config, section = config.split('#')
        else:
            section = 'chapman'
        _setup_logging(config)
        cp = ConfigParser()
        cp.read(config)
        settings = dict(cp.items(section))
        app_section = settings.pop('app')
        app_context = bootstrap('{}#{}'.format(config, app_section))
        settings = cls.settings_schema.to_python(settings)
        if args['--name']:
            settings['name'] = args['--name']
        self = cls(**settings)
        self.run(
            app_context['app'],
            app_context['registry'],
            int(args['--concurrency']),
            bool(args['--debug']))


    def run(self, app, registry, concurrency, debug):
        name = '{}:{}'.format(self.name, os.getpid())
        log.info('Starting Chapman')
        log.info('    path:        %s', self.path)
        log.info('    name:        %s', name)
        log.info('    queues:      %s', self.queues)
        log.info('    concurrency: %s', concurrency)
        log.info('    debug:       %s', debug)
        log.info('    sleep_ms:    %s', self.sleep_ms)
        w = worker.Worker(
            app=app,
            name=name,
            qnames=self.queues,
            chapman_path=self.path,
            registry=registry,
            num_threads=concurrency,
            sleep=self.sleep_ms / 1000.0,
            raise_errors=debug)
        w.start()
        w.run()
Beispiel #6
0
class SettingsSchema(fes.Schema):
    pre_validators = [fevd.NestedVariables()]
    uri = fev.String()
    key = fes.Schema(broker=KeySchema(), client=KeySchema(), if_missing=None)