Skip to content

Instantly share code, notes, and snippets.

@vikramdurai
Created April 20, 2017 04:09
Show Gist options
  • Save vikramdurai/fbcc611f14f06e77257d2bebbb684729 to your computer and use it in GitHub Desktop.
Save vikramdurai/fbcc611f14f06e77257d2bebbb684729 to your computer and use it in GitHub Desktop.
a simple task runner
""""
A simple task runner like Grunt or Gulp for Python, but uses only two types of tasks:
`build` and `concat`. Will extend for more tasks, like `clean` and `compile`.
"""
class task:
def __init__(self, actionfile, run=True, concat=False, concat_file=False, concat_new_file=False):
self.file = actionfile
if concat:
self.concat = True
self.other_file = concat_file
self.new_file = concat_new_file
def run(self):
if self.build:
with open(self.file) as build:
eval(build)
elif self.concat:
one = str(open(self.file))
two = str(open(self.concat_file))
three = open(self.new_file)
print(str(one + two), file=three)
if __name__ == "__main__":
with open("taskfile.py") as tasks:
eval(tasks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment