Skip to content

Commit

Permalink
Use pathlib's open (for compatibility with py3.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed Apr 10, 2020
1 parent b377f7b commit 71d3fc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.rst
Expand Up @@ -123,10 +123,10 @@ For example, it can be used to replicate some template files with randomized nam
content = f.read()
sources.append((srcfile.suffix, content))
for srcfile in itertools.cycle(sources):
name = target_dir / (randomfiletree.core.random_string() + srcfile[0])
with open(name, 'wb') as f:
path = target_dir / (randomfiletree.core.random_string() + srcfile[0])
with path.open('wb') as f:
f.write(srcfile[1])
yield name
yield path
randomfiletree.core.iterative_gaussian_tree(
"/path/to/basedir",
Expand Down
6 changes: 3 additions & 3 deletions randomfiletree/test/test_core.py
Expand Up @@ -86,10 +86,10 @@ def test_payload(self):

def callback(target_dir: pathlib.Path) -> pathlib.Path:
while True:
name = target_dir / (random_string() + suffix)
with open(name, 'w') as f:
path = target_dir / (random_string() + suffix)
with path.open('w') as f:
f.write(content)
yield name
yield path

iterative_gaussian_tree(
self.basedir.name, 3, 2, 5, maxdepth=3, payload=callback
Expand Down

0 comments on commit 71d3fc8

Please sign in to comment.