dk-tasklib 3.0.6__tar.gz → 3.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/PKG-INFO +26 -4
  2. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/README.rst +15 -0
  3. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/PKG-INFO +26 -4
  4. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/SOURCES.txt +30 -1
  5. dk_tasklib-3.0.8/dk_tasklib.egg-info/entry_points.txt +2 -0
  6. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/requires.txt +0 -1
  7. dk_tasklib-3.0.8/dktasklib/_version.py +1 -0
  8. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/commands.py +2 -3
  9. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/docs.py +2 -2
  10. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/entry_points/confbase.py +3 -1
  11. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/entry_points/dktasklibcmd.py +2 -1
  12. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/entry_points/pytemplate.py +3 -1
  13. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/executables.py +2 -2
  14. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/jstools.py +2 -2
  15. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/pset.py +1 -1
  16. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/rule.py +16 -18
  17. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/runners.py +4 -7
  18. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/upversion.py +3 -8
  19. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/urlinliner.py +11 -11
  20. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/utils.py +14 -10
  21. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/version.py +3 -2
  22. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/watch.py +4 -3
  23. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/wintask.py +5 -5
  24. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/setup.py +1 -2
  25. dk_tasklib-3.0.8/tests/test_clean.py +21 -0
  26. dk_tasklib-3.0.8/tests/test_commands_and_runners.py +115 -0
  27. dk_tasklib-3.0.8/tests/test_concat.py +60 -0
  28. dk_tasklib-3.0.8/tests/test_dktasklib_import.py +64 -0
  29. dk_tasklib-3.0.8/tests/test_docs.py +36 -0
  30. dk_tasklib-3.0.8/tests/test_docs_behavior.py +143 -0
  31. dk_tasklib-3.0.8/tests/test_entry_points_behavior.py +79 -0
  32. dk_tasklib-3.0.8/tests/test_executables.py +3 -0
  33. dk_tasklib-3.0.8/tests/test_executables_behavior.py +172 -0
  34. dk_tasklib-3.0.8/tests/test_help_behavior.py +13 -0
  35. dk_tasklib-3.0.8/tests/test_jstools.py +65 -0
  36. dk_tasklib-3.0.8/tests/test_jstools_behavior.py +165 -0
  37. dk_tasklib-3.0.8/tests/test_lessc.py +116 -0
  38. dk_tasklib-3.0.8/tests/test_lessc_behavior.py +108 -0
  39. dk_tasklib-3.0.8/tests/test_manage_behavior.py +130 -0
  40. dk_tasklib-3.0.8/tests/test_npm.py +20 -0
  41. dk_tasklib-3.0.8/tests/test_package_ini.py +97 -0
  42. dk_tasklib-3.0.8/tests/test_package_json.py +90 -0
  43. dk_tasklib-3.0.8/tests/test_package_setup.py +82 -0
  44. dk_tasklib-3.0.8/tests/test_packageinfo.py +18 -0
  45. dk_tasklib-3.0.8/tests/test_pset.py +110 -0
  46. dk_tasklib-3.0.8/tests/test_publish.py +51 -0
  47. dk_tasklib-3.0.8/tests/test_rule.py +28 -0
  48. dk_tasklib-3.0.8/tests/test_rule_and_watch.py +126 -0
  49. dk_tasklib-3.0.8/tests/test_taskbase_behavior.py +94 -0
  50. dk_tasklib-3.0.8/tests/test_upversion_behavior.py +100 -0
  51. dk_tasklib-3.0.8/tests/test_urlinliner_and_npm.py +82 -0
  52. dk_tasklib-3.0.8/tests/test_utils_behavior.py +121 -0
  53. dk_tasklib-3.0.8/tests/test_version.py +98 -0
  54. dk-tasklib-3.0.6/dk_tasklib.egg-info/entry_points.txt +0 -5
  55. dk-tasklib-3.0.6/dktasklib/_version.py +0 -1
  56. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/dependency_links.txt +0 -0
  57. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/not-zip-safe +0 -0
  58. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dk_tasklib.egg-info/top_level.txt +0 -0
  59. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/__init__.py +0 -0
  60. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/clean.py +0 -0
  61. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/concat.py +0 -0
  62. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/entry_points/__init__.py +0 -0
  63. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/entry_points/taskbase.py +0 -0
  64. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/environment.py +0 -0
  65. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/help.py +0 -0
  66. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/lessc.py +0 -0
  67. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/manage.py +0 -0
  68. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/npm.py +0 -0
  69. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/package/__init__.py +0 -0
  70. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/package/package_interface.py +0 -0
  71. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/dktasklib/publish.py +0 -0
  72. {dk-tasklib-3.0.6 → dk_tasklib-3.0.8}/setup.cfg +0 -0
@@ -1,12 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dk-tasklib
3
- Version: 3.0.6
3
+ Version: 3.0.8
4
4
  Summary: dk-tasklib - pyinvoke task library
5
5
  Home-page: https://github.com/datakortet/dk-tasklib
6
6
  Author: Bjorn Pettersen
7
7
  Author-email: bp@datakortet.no
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
8
  Classifier: Development Status :: 3 - Alpha
11
9
  Classifier: Intended Audience :: Developers
12
10
  Classifier: Programming Language :: Python
@@ -15,6 +13,17 @@ Classifier: Programming Language :: Python :: 2.7
15
13
  Classifier: Programming Language :: Python :: 3
16
14
  Classifier: Programming Language :: Python :: 3.5
17
15
  Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Dist: invoke
17
+ Requires-Dist: PyYAML
18
+ Requires-Dist: dkfileutils>=1.4.2
19
+ Requires-Dist: yamldirs>=1.1.8
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
18
27
 
19
28
 
20
29
  .. image:: https://travis-ci.org/datakortet/dk-tasklib.svg?branch=master
@@ -54,3 +63,16 @@ to make local changes to the source code.
54
63
  See docs/ folder for documentation.
55
64
 
56
65
 
66
+ Development
67
+ -----------
68
+
69
+ Run the authoritative package checks from the repository root::
70
+
71
+ dk testpackage
72
+
73
+ The suite enforces branch-aware coverage of at least 83 percent. Build the
74
+ documentation with::
75
+
76
+ dk docs
77
+
78
+ The documentation is maintained against current Sphinx 8 and 9 releases.
@@ -34,3 +34,18 @@ to make local changes to the source code.
34
34
 
35
35
 
36
36
  See docs/ folder for documentation.
37
+
38
+
39
+ Development
40
+ -----------
41
+
42
+ Run the authoritative package checks from the repository root::
43
+
44
+ dk testpackage
45
+
46
+ The suite enforces branch-aware coverage of at least 83 percent. Build the
47
+ documentation with::
48
+
49
+ dk docs
50
+
51
+ The documentation is maintained against current Sphinx 8 and 9 releases.
@@ -1,12 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dk-tasklib
3
- Version: 3.0.6
3
+ Version: 3.0.8
4
4
  Summary: dk-tasklib - pyinvoke task library
5
5
  Home-page: https://github.com/datakortet/dk-tasklib
6
6
  Author: Bjorn Pettersen
7
7
  Author-email: bp@datakortet.no
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
8
  Classifier: Development Status :: 3 - Alpha
11
9
  Classifier: Intended Audience :: Developers
12
10
  Classifier: Programming Language :: Python
@@ -15,6 +13,17 @@ Classifier: Programming Language :: Python :: 2.7
15
13
  Classifier: Programming Language :: Python :: 3
16
14
  Classifier: Programming Language :: Python :: 3.5
17
15
  Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Dist: invoke
17
+ Requires-Dist: PyYAML
18
+ Requires-Dist: dkfileutils>=1.4.2
19
+ Requires-Dist: yamldirs>=1.1.8
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
18
27
 
19
28
 
20
29
  .. image:: https://travis-ci.org/datakortet/dk-tasklib.svg?branch=master
@@ -54,3 +63,16 @@ to make local changes to the source code.
54
63
  See docs/ folder for documentation.
55
64
 
56
65
 
66
+ Development
67
+ -----------
68
+
69
+ Run the authoritative package checks from the repository root::
70
+
71
+ dk testpackage
72
+
73
+ The suite enforces branch-aware coverage of at least 83 percent. Build the
74
+ documentation with::
75
+
76
+ dk docs
77
+
78
+ The documentation is maintained against current Sphinx 8 and 9 releases.
@@ -37,4 +37,33 @@ dktasklib/entry_points/dktasklibcmd.py
37
37
  dktasklib/entry_points/pytemplate.py
38
38
  dktasklib/entry_points/taskbase.py
39
39
  dktasklib/package/__init__.py
40
- dktasklib/package/package_interface.py
40
+ dktasklib/package/package_interface.py
41
+ tests/test_clean.py
42
+ tests/test_commands_and_runners.py
43
+ tests/test_concat.py
44
+ tests/test_dktasklib_import.py
45
+ tests/test_docs.py
46
+ tests/test_docs_behavior.py
47
+ tests/test_entry_points_behavior.py
48
+ tests/test_executables.py
49
+ tests/test_executables_behavior.py
50
+ tests/test_help_behavior.py
51
+ tests/test_jstools.py
52
+ tests/test_jstools_behavior.py
53
+ tests/test_lessc.py
54
+ tests/test_lessc_behavior.py
55
+ tests/test_manage_behavior.py
56
+ tests/test_npm.py
57
+ tests/test_package_ini.py
58
+ tests/test_package_json.py
59
+ tests/test_package_setup.py
60
+ tests/test_packageinfo.py
61
+ tests/test_pset.py
62
+ tests/test_publish.py
63
+ tests/test_rule.py
64
+ tests/test_rule_and_watch.py
65
+ tests/test_taskbase_behavior.py
66
+ tests/test_upversion_behavior.py
67
+ tests/test_urlinliner_and_npm.py
68
+ tests/test_utils_behavior.py
69
+ tests/test_version.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dk-tasklib = dktasklib.entry_points.dktasklibcmd:main
@@ -1,5 +1,4 @@
1
1
  invoke
2
2
  PyYAML
3
3
  dkfileutils>=1.4.2
4
- pathtools
5
4
  yamldirs>=1.1.8
@@ -0,0 +1 @@
1
+ __version__ = '3.0.8'
@@ -5,7 +5,6 @@ import invoke
5
5
 
6
6
  from .executables import exe
7
7
  from .utils import fmt
8
- from past.builtins import basestring
9
8
 
10
9
 
11
10
  default_command_policy = dict(
@@ -58,12 +57,12 @@ class Command(object):
58
57
  res += flag
59
58
  else:
60
59
  if self.policy['negative_bool'] == 'prefix':
61
- res += '--no' + flag
60
+ res += '--no-' + flag.lstrip('-')
62
61
 
63
62
  elif isinstance(v, (list, tuple)) and v:
64
63
  res += flag + '=' + self.policy['list_join'].join(str(item) for item in v)
65
64
 
66
- elif isinstance(v, basestring):
65
+ elif isinstance(v, str):
67
66
  res += flag + '="%s"' % v
68
67
 
69
68
  else:
@@ -96,7 +96,7 @@ def create_docs_directory(ctx, force=False):
96
96
  ctx.pkg.docs.makedirs('_templates')
97
97
  confbase = DIRNAME / 'entry_points/confbase.py'
98
98
  txt = confbase.read('rb')
99
- txt = txt.replace('\r\n', '\n')
99
+ txt = txt.replace(b'\r\n', b'\n')
100
100
  t = PyTemplate(txt)
101
101
 
102
102
  (ctx.pkg.docs / 'conf.py').write(t.substitute(
@@ -117,7 +117,7 @@ def create_index(ctx, force=False):
117
117
  sys.exit(1)
118
118
  confbase = DIRNAME / 'entry_points/index.rst'
119
119
  txt = confbase.read('rb')
120
- txt = txt.replace('\r\n', '\n')
120
+ txt = txt.replace(b'\r\n', b'\n')
121
121
  t = PyTemplate(txt)
122
122
 
123
123
  index.write(t.substitute(
@@ -164,7 +164,9 @@ texinfo_documents = [
164
164
  # -- Options for intersphinx extension ---------------------------------------
165
165
 
166
166
  # Example configuration for intersphinx: refer to the Python standard library.
167
- intersphinx_mapping = {'https://docs.python.org/': None}
167
+ intersphinx_mapping = {
168
+ 'python': ('https://docs.python.org/3', None),
169
+ }
168
170
 
169
171
  # -- Options for todo extension ----------------------------------------------
170
172
 
@@ -49,6 +49,7 @@ def create_docs_cmd(args):
49
49
  txt = txt.replace(b'\r\n', b'\n')
50
50
  t = PyTemplate(txt)
51
51
 
52
+ docsdir.makedirs()
52
53
  (docsdir / 'conf.py').write(t.substitute(
53
54
  VERSION=run('python setup.py --version'),
54
55
  PACKAGE=run('python setup.py --name'),
@@ -64,7 +65,7 @@ def add_django_to_docs_conf():
64
65
  print("./docs/conf.py already contains django.setup()")
65
66
  return
66
67
 
67
- src = conf_file.read('rT')
68
+ src = conf_file.read('r')
68
69
  pre, post = src.split('\n\n', 1)
69
70
  conf_file.write(
70
71
  pre + "\n\n" +
@@ -7,7 +7,9 @@ class PyTemplate(Template):
7
7
  Template strings that can replace ##{PATTERN} instances.
8
8
  """
9
9
  def __init__(self, t):
10
- super(PyTemplate, self).__init__(t.replace(b'$', b'$$').replace(b'##{', b'${'))
10
+ if isinstance(t, bytes):
11
+ t = t.decode('u8')
12
+ super(PyTemplate, self).__init__(t.replace('$', '$$').replace('##{', '${'))
11
13
 
12
14
  def substitute(self, *args, **kw):
13
15
  return super(PyTemplate, self).substitute(
@@ -82,9 +82,9 @@ class Executables(object):
82
82
  if win32:
83
83
  # self.ctx.run(cmd, echo=True)
84
84
  runners.run(cmd)
85
- wheel = get_executable(exename)
85
+ exepath = get_executable(exename)
86
86
  # generate signing key if downloading wheel
87
- runners.run(wheel + ' keygen')
87
+ runners.run(exepath + ' keygen')
88
88
  else:
89
89
  raise MissingCommand("Missing wheel (%s)" % cmd)
90
90
  print('Your ~/.pypirc file should have a [pypi] section instead of a [server-login] section')
@@ -241,9 +241,9 @@ def browserify(ctx,
241
241
  ctx.run(cmd)
242
242
  with open(dest, 'rb') as fp:
243
243
  txt = fp.read()
244
- if '\r\n' in txt:
244
+ if b'\r\n' in txt:
245
245
  with open(dest, 'wb') as fp:
246
- fp.write(txt.replace('\r\n', '\n'))
246
+ fp.write(txt.replace(b'\r\n', b'\n'))
247
247
  return dest
248
248
 
249
249
 
@@ -50,7 +50,7 @@ class pset(dict):
50
50
  """
51
51
  if other is None:
52
52
  return False
53
- if type(other) == dict:
53
+ if type(other) is dict:
54
54
  return dict.__eq__(self, other)
55
55
  # noinspection PyProtectedMember
56
56
  if set(self._order) == set(other._order): # pylint: disable=W0212
@@ -48,28 +48,26 @@ class BuildRule(object):
48
48
  def topsort(self, tasklist):
49
49
  """Topological sort
50
50
  """
51
- # id(t) was originally t.__name__, id(t) means there will be no sharing...
52
- tasks = {id(t): t for t in tasklist}
51
+ permanent = set()
52
+ temporary = set()
53
53
  res = []
54
54
 
55
- def visit(name, task):
56
- if task._temp_mark:
55
+ def visit(task):
56
+ name = id(task)
57
+ if name in temporary:
57
58
  raise ValueError("Circularity", name, res)
58
- if not task._perm_mark:
59
- task._temp_mark = True
60
- for d in task.requires:
61
- visit(d, tasks[d])
62
- task._perm_mark = True
63
- task._temp_mark = False
64
- res.append(name)
59
+ if name in permanent:
60
+ return
61
+ temporary.add(name)
62
+ for dependency in task.requires:
63
+ visit(dependency)
64
+ permanent.add(name)
65
+ temporary.remove(name)
66
+ res.append(task)
65
67
 
66
- while 1:
67
- unmarked = set((name, task) for name, task in tasks.items()
68
- if not (task._perm_mark or task._temp_mark))
69
- if not unmarked:
70
- return [tasks[k] for k in res]
71
- name, task = unmarked.pop()
72
- visit(name, task)
68
+ for task in tasklist:
69
+ visit(task)
70
+ return res
73
71
 
74
72
 
75
73
  # @task
@@ -10,18 +10,15 @@ class Result(str):
10
10
 
11
11
  def run(cmdline, throw=False):
12
12
  try:
13
- res = Result(
14
- subprocess.check_output(
15
- cmdline,
16
- shell=True
17
- ) # .decode('u8') ## (can't decode since Result is a str)
18
- )
13
+ output = subprocess.check_output(cmdline, shell=True)
14
+ res = Result(output.decode('u8'))
19
15
  res.cmd = cmdline
20
16
  return res
21
17
  except subprocess.CalledProcessError as e:
22
18
  if throw:
23
19
  raise
24
- res = Result(e.output)
20
+ output = e.output.decode('u8') if isinstance(e.output, bytes) else e.output
21
+ res = Result(output)
25
22
  res.cmd = cmdline
26
23
  res.returncode = e.returncode
27
24
  return res
@@ -47,13 +47,8 @@ def _replace_version(fname, cur_version, new_version):
47
47
  with open(fname, 'rb') as fp:
48
48
  txt = fp.read()
49
49
 
50
- try:
51
- cur_version in txt
52
- uc = False
53
- except UnicodeDecodeError:
54
- uc = True
55
- txt = txt.decode('u8')
56
-
50
+ cur_version = cur_version.encode('u8')
51
+ new_version = new_version.encode('u8')
57
52
  if cur_version not in txt: # pragma: nocover
58
53
  # warnings.warn("Did not find %r in %r" % (cur_version, fname))
59
54
  return False
@@ -67,7 +62,7 @@ def _replace_version(fname, cur_version, new_version):
67
62
  txt = txt.replace(cur_version, new_version)
68
63
 
69
64
  with open(fname, 'wb') as fp:
70
- fp.write(txt if not uc else txt.encode('u8'))
65
+ fp.write(txt)
71
66
  return 1
72
67
 
73
68
 
@@ -5,7 +5,7 @@ from dktasklib.wintask import task
5
5
  import base64
6
6
  import os
7
7
  import re
8
- import urllib
8
+ from urllib.request import urlopen
9
9
 
10
10
 
11
11
  def inline_data(data, type='image/png', name=""):
@@ -15,7 +15,7 @@ def inline_data(data, type='image/png', name=""):
15
15
  print("%s is too big (%d bytes), max is 10KB" % (name, len(data)))
16
16
  return name
17
17
 
18
- encoded = base64.b64encode(data)
18
+ encoded = base64.b64encode(data).decode('ascii')
19
19
  return 'data:{type};base64,{encoded}'.format(
20
20
  type=type,
21
21
  encoded=encoded.replace('\n', '')
@@ -36,12 +36,12 @@ def inline_file(fname):
36
36
  def inline_url(uri):
37
37
  """Fetch ``uri`` and inline.
38
38
  """
39
- fp = urllib.urlopen(uri)
40
- return inline_data(
41
- fp.read(),
42
- type=fp.headers['Content-Type'],
43
- name=uri
44
- )
39
+ with urlopen(uri) as fp:
40
+ return inline_data(
41
+ fp.read(),
42
+ type=fp.headers['Content-Type'],
43
+ name=uri
44
+ )
45
45
 
46
46
 
47
47
  @task(
@@ -69,7 +69,7 @@ def inline(ctx, fname):
69
69
  """
70
70
  lines = open(fname).readlines()
71
71
  output_fname = os.path.splitext(fname)[0]
72
- with open(output_fname, 'wb') as fp:
72
+ with open(output_fname, 'w') as fp:
73
73
  for line in lines:
74
74
  if line.startswith('@'):
75
75
  varname, content = line.split(':', 1)
@@ -82,12 +82,12 @@ def inline(ctx, fname):
82
82
  varname=varname,
83
83
  content=data
84
84
  )
85
- fp.writelines([line])
85
+ fp.write(line)
86
86
 
87
87
 
88
88
  @task
89
89
  def list_urls(ctx, filename):
90
90
  """List all url(..) targets in the filename.
91
91
  """
92
- for match in re.findall(r'url\((.*?)\)', open(filename, 'rb').read()):
92
+ for match in re.findall(r'url\((.*?)\)', open(filename).read()):
93
93
  print(match)
@@ -125,7 +125,7 @@ def dest_is_newer_than_source(src, dst):
125
125
  if not os.path.exists(dst):
126
126
  return False
127
127
  if not os.path.exists(src):
128
- raise ValueError("Source does not exist: " + src)
128
+ raise ValueError("Source does not exist: " + str(src))
129
129
  return os.path.getmtime(src) < os.path.getmtime(dst)
130
130
 
131
131
 
@@ -186,12 +186,14 @@ def env(**kw):
186
186
  currentvals = {k: os.environ.get(k) for k in kw}
187
187
  for k, v in kw.items():
188
188
  os.environ[k] = str(v)
189
- yield
190
- for k in kw:
191
- if currentvals[k] is None:
192
- os.unsetenv(k)
193
- else:
194
- os.environ[k] = currentvals[k]
189
+ try:
190
+ yield
191
+ finally:
192
+ for k in kw:
193
+ if currentvals[k] is None:
194
+ os.environ.pop(k, None)
195
+ else:
196
+ os.environ[k] = currentvals[k]
195
197
 
196
198
 
197
199
  @contextmanager
@@ -206,9 +208,11 @@ def cd(directory):
206
208
 
207
209
  """
208
210
  cwd = os.getcwd()
209
- os.chdir(directory)
210
- yield
211
- os.chdir(cwd)
211
+ try:
212
+ os.chdir(directory)
213
+ yield
214
+ finally:
215
+ os.chdir(cwd)
212
216
 
213
217
 
214
218
  def find_pymodule(dotted_name):
@@ -51,7 +51,8 @@ def get_version(ctx, fname, kind='pkg'):
51
51
  return ctx.pkg.version
52
52
 
53
53
  elif kind == "hash":
54
- md5 = fname.dirname() / '.md5'
54
+ directory = fname.dirname() or Path('.')
55
+ md5 = directory / '.md5'
55
56
  if md5.exists():
56
57
  return md5.open().read()
57
58
  return hashlib.md5(open(fname, 'rb').read()).hexdigest()
@@ -77,7 +78,7 @@ def copy_to_version(ctx, source, outputdir=None, kind="pkg", force=False):
77
78
  """
78
79
  # where to place the versioned file..
79
80
  source = Path(source)
80
- outputdir = Path(outputdir) if outputdir else source.dirname()
81
+ outputdir = Path(outputdir) if outputdir else source.dirname() or Path('.')
81
82
  outputdir.makedirs()
82
83
  dst_fname = source.basename()
83
84
  if '{version}' not in str(dst_fname):
@@ -40,7 +40,7 @@ class FileModified(FileSystemEventHandler):
40
40
  self.action = action
41
41
 
42
42
  def on_modified(self, event):
43
- if event.src_path != self.fname:
43
+ if Path(event.src_path).abspath() != self.fname:
44
44
  return
45
45
  self.action(event)
46
46
 
@@ -55,10 +55,11 @@ class DirectoryModified(FileSystemEventHandler):
55
55
 
56
56
  def on_modified(self, event):
57
57
  # print event.src_path, self.path, self.ext
58
- if not event.src_path.startswith(self.path):
58
+ event_path = Path(event.src_path).abspath()
59
+ if not event_path.startswith(self.path):
59
60
  # print ' path different'
60
61
  return
61
- if self.ext and not event.src_path.endswith(self.ext):
62
+ if self.ext and not event_path.endswith(self.ext):
62
63
  # print ' ext different'
63
64
  return
64
65
  self.action(event)
@@ -1,18 +1,18 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import os
3
3
  import sys
4
- import invoke
5
4
 
6
5
  try:
7
6
  from invoke import ctask as _task
8
7
  except ImportError:
9
8
  from invoke import task as _task
10
9
 
11
- if invoke.__version_info__ < (0, 22): # pragma: nocover
12
- _should_patch = True
13
- elif invoke.__version_info__ >= (0, 22):
14
- _should_patch = False
10
+ # if invoke.__version_info__ < (0, 22): # pragma: nocover
11
+ # _should_patch = True
12
+ # elif invoke.__version_info__ >= (0, 22):
13
+ # _should_patch = False
15
14
 
15
+ _should_patch = False
16
16
 
17
17
  if _should_patch: # pragma: nocover
18
18
  # https://github.com/pyinvoke/invoke/pull/407
@@ -18,7 +18,7 @@ Programming Language :: Python :: 3.5
18
18
  Topic :: Software Development :: Libraries
19
19
  """
20
20
 
21
- version = '3.0.6'
21
+ version = '3.0.8'
22
22
  DIRNAME = os.path.dirname(__file__)
23
23
 
24
24
 
@@ -29,7 +29,6 @@ setuptools.setup(
29
29
  "invoke",
30
30
  "PyYAML",
31
31
  "dkfileutils>=1.4.2",
32
- "pathtools",
33
32
  "yamldirs>=1.1.8",
34
33
  ],
35
34
  author='Bjorn Pettersen',
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import os
4
+
5
+ from yamldirs import create_files
6
+ from dktasklib import clean
7
+
8
+
9
+ def test_clean(ctx):
10
+ files = """
11
+ build:
12
+ - a
13
+ - b
14
+ - c:
15
+ - d
16
+ - e
17
+ """
18
+ with create_files(files) as directory:
19
+ clean.clean(ctx.init(), 'c')
20
+ assert set(os.listdir('build')) == {'a', 'b', 'c'}
21
+ assert os.listdir('build/c') == []