rndusr / torf

Python module to create, parse and edit torrent files and magnet links
GNU General Public License v3.0
180 stars 17 forks source link

Question remove file #20

Closed romanoh closed 3 years ago

romanoh commented 3 years ago

Sorry for the question as i am new to python, i work with the code:

t = Torrent(path=folder_path,
trackers=['https://example:2910/announce'],                                     
t.private = True
t.generate()

and it works, but if i want to remove the file who as an extension .nfo per example i write the t.exclude_globs('*.nfo'), and it gives me an error, what i am doing wrong please.

t.exclude_globs('*.nfo') gives an error: maybe its not torf fault: imagem

i get the folder path from pysimplegui, like this: file_path = values[1]

the debug: imagem

rndusr commented 3 years ago

I don't understand the question.

t.exclude_globs('*.nfo') works but t.exclude_globs('*.nfo') doesn't? Where's the difference?

And ALWAYS provide the error message. You wouldn't go to the doctor and ask for help without explaining what's wrong.

romanoh commented 3 years ago

Sorry for my bad English, question edited.

rndusr commented 3 years ago

Your English is great, but your asking for help sucks. :)

Never post errors as screenshots. Just copy and paste them. And always provide the complete error message (starting from "Traceback").

Also post the code that gives you the error, not the code that works. If I can't reproduce the same problem you have, it's impossible for me to figure out what's wrong.

romanoh commented 3 years ago

Ok, i made a new py file, eliminate everything, and use this code:

folder_path = "D:/TORRENT FILE/Before the End"
file_path = ''
if file_path == '':
    print('INFO-Tor: Creating Torrent...please wait')
    # Make torrent from folder
    t = Torrent(path=folder_path,
                trackers=['https://example.me:2910/announce'],
                comment='some comment ')

    t.exclude_globs('*.nfo')

    t.private = True
    t.generate()
    t.write(folder_path + '.torrent')

The error is:

Traceback (most recent call last):
  File "D:\folder\test---2.py", line 98, in <module>
    t.exclude_globs('*.nfo')
TypeError: 'MonitoredList' object is not callable

and the traceback from debug:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/folder/test---2.py", line 13, in <module>
    t.exclude_globs('*.nfo')
TypeError: 'MonitoredList' object is not callable

thank you for the torf and help.

rndusr commented 3 years ago

OK, I see what's wrong. I don't know why I didn't see that earlier.

exclude_gobs is not a method, it's a property. You can use it like a list.

t.exlude_globs.append('.nfo') t.exlude_globs.extend(['.jpg', '.png']) t.exlude_globs = ['.foo', '*.bar']

romanoh commented 3 years ago

Thank you.