Skip to content

Commit 7128e7b

Browse files
authored
Merge pull request #100 from alexpdev/Fixes_#96
updated changelog and fixed coverage gaps
2 parents 8867a5e + 733f6f8 commit 7128e7b

File tree

10 files changed

+167
-6
lines changed

10 files changed

+167
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# TorrentFile
22

3+
## Version 0.6.13
4+
5+
- Fixed bug that created a torrent file with no name.
6+
- Fixed bug that would error if cli path was listed after announce urls
7+
- Added full unicode support.
8+
- Added Unittests for new features and bug fixes
9+
10+
---------------------
11+
312
## Version 0.6.11
413

514
- Fixed bug that occured during recheck when file of 0 length is included.

docs/changelog/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@
306306
</label>
307307
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
308308

309+
<li class="md-nav__item">
310+
<a href="#version-0613" class="md-nav__link">
311+
Version 0.6.13
312+
</a>
313+
314+
</li>
315+
309316
<li class="md-nav__item">
310317
<a href="#version-0611" class="md-nav__link">
311318
Version 0.6.11
@@ -580,6 +587,13 @@
580587
</label>
581588
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
582589

590+
<li class="md-nav__item">
591+
<a href="#version-0613" class="md-nav__link">
592+
Version 0.6.13
593+
</a>
594+
595+
</li>
596+
583597
<li class="md-nav__item">
584598
<a href="#version-0611" class="md-nav__link">
585599
Version 0.6.11
@@ -809,6 +823,14 @@
809823

810824

811825
<h1 id="torrentfile">TorrentFile</h1>
826+
<h2 id="version-0613">Version 0.6.13</h2>
827+
<ul>
828+
<li>Fixed bug that created a torrent file with no name.</li>
829+
<li>Fixed bug that would error if cli path was listed after announce urls</li>
830+
<li>Added full unicode support.</li>
831+
<li>Added Unittests for new features and bug fixes</li>
832+
</ul>
833+
<hr />
812834
<h2 id="version-0611">Version 0.6.11</h2>
813835
<ul>
814836
<li>Fixed bug that occured during recheck when file of 0 length is included.</li>

docs/objects.inv

8 Bytes
Binary file not shown.

docs/search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/sitemap.xml.gz

0 Bytes
Binary file not shown.

docs/source/index.html

Lines changed: 88 additions & 4 deletions
Large diffs are not rendered by default.

site/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# TorrentFile
22

3+
## Version 0.6.13
4+
5+
- Fixed bug that created a torrent file with no name.
6+
- Fixed bug that would error if cli path was listed after announce urls
7+
- Added full unicode support.
8+
- Added Unittests for new features and bug fixes
9+
10+
---------------------
11+
312
## Version 0.6.11
413

514
- Fixed bug that occured during recheck when file of 0 length is included.

tests/test_cli.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,35 @@ def test_cli_announce_path(dir2, flag):
438438
sys.argv = args
439439
main()
440440
assert os.path.exists(str(dir2) + ".torrent")
441+
442+
443+
@pytest.mark.parametrize("version", ["1", "2", "3"])
444+
def test_cli_unicode_path(version):
445+
"""
446+
Test creating a new torrent file with unicode characters.
447+
"""
448+
text = "丂七万丈三上下丌不与丏丑丒专且丕世丗丘丙业丛东丝丠両丢丣两严丩个丫丬中丮丯"
449+
parent = os.path.dirname(__file__)
450+
dest = os.path.join(parent, text)
451+
with open(dest, "wb") as tempfile:
452+
l = 0
453+
out = text
454+
while l < 1 << 18:
455+
tempfile.write((out + "\n").encode("utf-8"))
456+
l += len(out)
457+
out += out
458+
args = [
459+
"torrentfile",
460+
"create",
461+
"--private",
462+
"-a",
463+
"https://tracker1.org",
464+
"https://tracker2.org",
465+
"--meta-version",
466+
version,
467+
dest,
468+
]
469+
sys.argv = args
470+
main()
471+
assert os.path.exists(dest)
472+
rmpath(dest)

torrentfile/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ def execute(args=None):
146146
args = sys.argv[1:]
147147
else:
148148
args = ["-h"]
149-
150149
parser = ArgumentParser(
151150
"torrentfile",
152151
description="""
@@ -456,6 +455,10 @@ def execute(args=None):
456455

457456
info_parser.set_defaults(func=info_command)
458457

458+
for i, arg in enumerate(args):
459+
if hasattr(arg, "decode"):
460+
args[i] = args[i].decode("utf-8") # pragma: nocover
461+
459462
args = parser.parse_args(args)
460463
if args.debug:
461464
torrentfile.add_handler()

torrentfile/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def filelist_total(pathstring: str) -> os.PathLike:
165165
MissingPathError
166166
File could not be found.
167167
"""
168+
if hasattr(pathstring, "decode"):
169+
pathstring = pathstring.decode("utf-8") # pragma: nocover
168170
if os.path.exists(pathstring):
169171
path = Path(pathstring)
170172
return _filelist_total(path)

0 commit comments

Comments
 (0)