mirror of https://github.com/captn3m0/Scripts.git
Add some more comments
This commit is contained in:
parent
1a7634b490
commit
032e0ac0c9
|
@ -16,25 +16,36 @@ Most common options you might want to overwrite are
|
||||||
--name
|
--name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Remove the script name
|
||||||
arguments = sys.argv
|
arguments = sys.argv
|
||||||
del arguments[0]
|
del arguments[0]
|
||||||
|
|
||||||
|
# Last argument must be the directory or file
|
||||||
directory = sys.argv[-1]
|
directory = sys.argv[-1]
|
||||||
comment = None
|
comment = None
|
||||||
for file in ["README.txt", "readme.txt", "README.md", "readme.md", "README.nfo"]:
|
|
||||||
|
# Only try for a comment if we have a directory
|
||||||
|
if os.path.isdir(directory)
|
||||||
|
for file in ["README.txt", "readme.txt", "README.md", "readme.md", "README.nfo"]:
|
||||||
file_path = directory + "/" + file
|
file_path = directory + "/" + file
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
comment = f.read()
|
comment = f.read()
|
||||||
|
if !comment
|
||||||
if !comment:
|
|
||||||
print("Could not find a readme file in %s" % directory)
|
print("Could not find a readme file in %s" % directory)
|
||||||
|
|
||||||
|
# Add all trackers
|
||||||
tracker_file = os.path.expanduser('~/.config/trackers.txt')
|
tracker_file = os.path.expanduser('~/.config/trackers.txt')
|
||||||
with open(tracker_file, 'r') as t:
|
with open(tracker_file, 'r') as t:
|
||||||
list = ["mktorrent"] + ["--announce=%s" % x for x in t.read().split("\n")] + ['--no-date']
|
trackers = t.read().split("\n")
|
||||||
|
list = ["mktorrent"] + ["--announce=%s" % tracker_url for tracker_url in trackers] + ['--no-date']
|
||||||
|
|
||||||
|
# Add a comment if we found one
|
||||||
if comment:
|
if comment:
|
||||||
list+=["--comment=\"%s\""%comment]
|
list+=["--comment=\"%s\"" % comment]
|
||||||
|
|
||||||
|
# Append any extra arguments we got, including the directory
|
||||||
list += arguments
|
list += arguments
|
||||||
|
|
||||||
|
# Run and passthrough stdout (default)
|
||||||
subprocess.run(args=list)
|
subprocess.run(args=list)
|
Loading…
Reference in New Issue