Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rework directory structure

This way, I can both

import jug

in my scripts and run

jug

on my command line!
  • Loading branch information...
commit eedc9489f47d03fabbf6a89a6e5f6bde93841e6b 1 parent 4866725
Luís Pedro Coelho authored
View
4 bin/jug
@@ -0,0 +1,4 @@
+#!/usr/bin/python
+
+import jug.jug
+jug.jug.main()
View
0  juglib/__init__.py → jug/__init__.py
File renamed without changes
View
0  juglib/addtemplate.py → jug/addtemplate.py
File renamed without changes
View
6 jug/jug.py
@@ -29,9 +29,9 @@
import os.path
import random
-import juglib.options as options
-from juglib.store import create_directories
-import juglib.task as task
+from . import options
+from . import task
+from .store import create_directories
def do_print():
'''
View
0  juglib/lock.py → jug/lock.py
File renamed without changes
View
0  juglib/options.py → jug/options.py
File renamed without changes
View
0  juglib/store.py → jug/store.py
File renamed without changes
View
2  juglib/task.py → jug/task.py
@@ -271,7 +271,7 @@ def load_recursive(elem):
Loads a task object recursively.
'''
- if type(elem) is juglib.task.Task:
+ if type(elem) is Task:
return elem.result
elif type(elem) is list:
return [load_recursive(e) for e in elem]
View
2  jugfile.py
@@ -1,4 +1,4 @@
-from juglib.task import Task, TaskGenerator
+from jug.task import Task, TaskGenerator
from time import sleep
@TaskGenerator
View
2  setup.py
@@ -64,7 +64,7 @@
classifiers = classifiers,
url = 'http://luispedro.org/jug',
packages = setuptools.find_packages(exclude='tests'),
- scripts = ['jug/jug.py'],
+ scripts = ['bin/jug'],
test_suite = 'nose.collector',
)
View
2  tests/test_lock.py
@@ -1,4 +1,4 @@
-from juglib import lock
+from jug import lock
def test_twice():
assert lock.get('foo')
assert not lock.get('foo')
View
54 tests/test_tasks.py
@@ -1,4 +1,4 @@
-import juglib.task
+import jug.task
def add1(x):
return x + 1
def add2(x):
@@ -14,34 +14,34 @@ def _assert_tsorted(tasks):
assert tasks[j] is not dep
def test_topological_sort():
- bases = [juglib.task.Task(add1,i) for i in xrange(10)]
- derived = [juglib.task.Task(add1,t) for t in bases]
- derived2 = [juglib.task.Task(add1,t) for t in derived]
- derived3 = [juglib.task.Task(add1,t) for t in derived]
+ bases = [jug.task.Task(add1,i) for i in xrange(10)]
+ derived = [jug.task.Task(add1,t) for t in bases]
+ derived2 = [jug.task.Task(add1,t) for t in derived]
+ derived3 = [jug.task.Task(add1,t) for t in derived]
alltasks = bases + derived
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks.reverse()
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = bases + derived
alltasks.reverse()
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = derived + bases
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = derived + bases + derived2
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = derived + bases + derived2 + derived3
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
def test_topological_sort_kwargs():
@@ -50,64 +50,64 @@ def add2(x):
def sumlst(lst,param):
return sum(lst)
- bases = [juglib.task.Task(add2,x=i) for i in xrange(10)]
- derived = [juglib.task.Task(sumlst,lst=bases,param=p) for p in xrange(4)]
+ bases = [jug.task.Task(add2,x=i) for i in xrange(10)]
+ derived = [jug.task.Task(sumlst,lst=bases,param=p) for p in xrange(4)]
alltasks = bases + derived
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks.reverse()
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = bases + derived
alltasks.reverse()
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
alltasks = derived + bases
- juglib.task.topological_sort(alltasks)
+ jug.task.topological_sort(alltasks)
_assert_tsorted(alltasks)
def test_load_after_run():
- T = juglib.task.Task(add1,1)
+ T = jug.task.Task(add1,1)
T.run()
assert T.can_load()
def test_hash_same_func():
- T0 = juglib.task.Task(add1,0)
- T1 = juglib.task.Task(add1,1)
+ T0 = jug.task.Task(add1,0)
+ T1 = jug.task.Task(add1,1)
assert T0.filename(hash_only=True) != T1.filename(hash_only=True)
assert T0.filename(hash_only=False) != T1.filename(hash_only=False)
def test_hash_different_func():
- T0 = juglib.task.Task(add1,0)
- T1 = juglib.task.Task(add2,0)
+ T0 = jug.task.Task(add1,0)
+ T1 = jug.task.Task(add2,0)
assert T0.filename(hash_only=True) != T1.filename(hash_only=True)
assert T0.filename(hash_only=False) != T1.filename(hash_only=False)
def test_taskgenerator():
- @juglib.task.TaskGenerator
+ @jug.task.TaskGenerator
def double(x):
return 2*x
T=double(2)
- assert type(T) == juglib.task.Task
+ assert type(T) == jug.task.Task
assert not T.print_result
- @juglib.task.TaskGenerator(print_result=True)
+ @jug.task.TaskGenerator(print_result=True)
def square(x):
return x*x
T=square(2)
- assert type(T) == juglib.task.Task
+ assert type(T) == jug.task.Task
assert T.print_result
def test_unload():
- T0 = juglib.task.Task(add1,0)
+ T0 = jug.task.Task(add1,0)
assert not T0.finished
assert T0.can_run()
T0.run()
Please sign in to comment.
Something went wrong with that request. Please try again.