Musket

File dependency tracking library
Download

Musket Ranking & Summary

Advertisement

  • Rating:
  • License:
  • ISC License
  • Price:
  • FREE
  • Publisher Name:
  • Bertrand Chenal
  • Publisher web site:
  • https://bitbucket.org/bertrandchenal/

Musket Tags


Musket Description

Musket is a file dependency tracking library. Musket is coverded by the ISC license.Musket allows to define compilers which in turn can be used to process files content and save the result in a new location. Musket will look at the modification time of the files to decide if the compiler must be run.ExamplesA Simple CompilerTo define a compiler we use the `@Compiler` decorator. @Compiler() def copy(src): return srcThe above compilator just return file content without modifications. We can use it to copy files: from glob import glob for source in glob('src/*txt'): target = source.replace('src/', 'trg/') copy(File(source)).save(target)Which will actually copy file content from source to target. On further invocation nothing will be done except if the source file is modified.TemplatesLet's use the string format method as a simple template. Here we pass the file containing the template to `@Compiler`. @Compiler(File('tpl/blockquote.html')) def template(tpl, content, **env): return tpl.format(content=content, **env)where `blockquote.html` contains: < blockquote > {content} < p >-- {author}< /p > < /blockquote >Our template function can be used like this: quote = template(File('TwoHardThings.txt'), author='Phil Karlton') quote.save('TwoHardThings.html')We see that when arguments are passed to `Compiler`, they are [partially applied to the decorated function.FileList and FileDictA compiler can be used to aggregate a collection of files. @compiler() def all_news(news): return '\n'.join(news) all_news(FileList('news/*txt')).save('all_news.txt')The `FileList` constructor accept a glob-like string to describe the file to read. `FileDict` can be used to build a list of file, where the keys are the file names.Product's homepage


Musket Related Software