<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_spec(spec):
 """Return a schema object from a spec. A spec is either a string for a scalar type, or a list of 0 or 1 specs, """

  if spec == '':
    return any_schema

  if framework.is_str(spec):
    # Scalar type
    if spec not in SCALAR_TYPES:
      raise exceptions.SchemaError('Not a valid schema type: %r' % spec)
    return ScalarSchema(spec)

  if framework.is_list(spec):
    return ListSchema(spec[0] if len(spec) else any_schema)

  if framework.is_tuple(spec):
    return TupleSchema(spec.get('fields', {}), spec.get('required', []))

  raise exceptions.SchemaError('Not valid schema spec; %r' % spec)