Stamp backer(Python)

  • hacker45
    10th Apr 2011 Member 0 Permalink
    what does that have to do with anything the scan came out clean so nvm
  • Marte2007
    10th Apr 2011 Member 0 Permalink
    Just to specify, .py files are PLAIN TEXT, don't contain binary data, so you can "scan" it by reading it (Python is also easy to understand even if you don't know it)
  • hacker45
    10th Apr 2011 Member 0 Permalink
    okay thanks
  • Onlyonedan
    19th Jul 2018 Member 0 Permalink

    boxmein:

    For future people, this does the same thing as reloading stamps in the Stamp Browser menu. There is no need for this script.



    Anyways.. here's the script.


    import os
    from argparse import ArgumentParser

    parser = ArgumentParser(description="Generate stamps.def from stamp files. TPT does that out of the box too.")

    parser.add_argument("-b", "--nobackup",
    action="store_true", help="Don't backup stamps.def before running.")

    parser.add_argument("-w", "--nowait",
    action="store_true", help="Don't wait for input after running.")

    parser.add_argument("-q", "--quiet",
    action="store_true", help="Shut up")

    args = parser.parse_args()
    qp = lambda s: None if args.quiet else print(s)

    # Backup
    if not args.nobackup:
    with open("stamps/stamps.def", 'r') as f:
    with open("stamps/stamps.def~", 'w') as g:
    for line in f:
    g.write(line)

    # True stuff
    dirlist = os.listdir(os.getcwd() + os.sep + "stamps" + os.sep)
    dirlist.remove("stamps.def")

    with open('stamps/stamps.def', 'w') as f:
    for i in range(0, len(dirlist)-1):
    f.write(dirlist[i].rstrip(".stm"))
    qp (repr(dirlist[i]) + " added to stamps.def")
    qp ("Success.")

    if not args.nowait:
    input()
    # 2011 original, 2013 rewritten for Python 3 support and arguments.
    # by boxmein. Use as you wish.

     yea but i dont understand how to use xd

  • jacob1
    20th Jul 2018 Developer 0 Permalink
    @Onlyonedan (View Post)
    Please do not necro old threads unless you have a good reason.

    This script is completely useless now, you can just click the "rescan stamps" button in game to have the same effect. You probably don't want to do that though unless you are sure there is an issue with your stamps.
Locked by jacob1: necro