Ejemplo n.º 1
0
def test_tokenize():
    eq_(list(tokenize_pattern("{artist}/{album}/{track}.{ext}")),
        ['{artist}', '/', '{album}', '/', '{track}', '.', '{ext}'])

    eq_(list(tokenize_pattern("{artist}/{album}/{track}-{date}.{ext}")), [
        '{artist}', '/', '{album}', '/', '{track}', '-', '{date}', '.', '{ext}'
    ])
Ejemplo n.º 2
0
def test_tokenize():
  eq_(
    list(tokenize_pattern("{artist}/{album}/{track}.{ext}")),
    ['{artist}','/','{album}','/','{track}', '.','{ext}'] 
  )

  eq_(
    list(tokenize_pattern("{artist}/{album}/{track}-{date}.{ext}")),
    ['{artist}','/','{album}','/','{track}', '-', '{date}', '.','{ext}'] 
  )
Ejemplo n.º 3
0
  def __init__(self,  name, root_dir, **options):
    self.name = name

    if not root_dir.endswith('/'):
      root_dir += '/'
    self.root_dir = root_dir

    self.pattern  = options.pop('pattern', None)

    if self.pattern:
      tokens = tokenize_pattern(self.pattern)
      self.path_schema = Schema([
        Field(name=c, type="STRING")
        for c in columns(tokens)
      ])



    self.content_column = options.pop('content_column', None)
    self.filename_column = options.pop('filename_column', None)
  
    self.decode = options.pop('decode', "none")

    schema = options.pop('schema',None)
    if isinstance(schema, Schema):
      self.schema = schema
    else:
      self.schema = schema and Schema(**schema)

    if options:
      raise ValueError("Unrecognized options {}".format(options.keys()))