Giter Site home page Giter Site logo

Comments (7)

sebix avatar sebix commented on July 18, 2024

You can use basic shell features:

while read line; do exrex.py "$line"; done < patternfile.txt

Or

cat patternfile.txt | xargs -n 1 exrex.py

from exrex.

zdilto avatar zdilto commented on July 18, 2024

i'm using windows so i tested powershell and cmd still didn't test this in bash yet (may work)
in my case this will start new instances of exrex and the exe for each line

for /f "tokens=*" %G in ('type patternfile.txt') do (exrex "%~G")|exe params

i have to take a pic whenever exe exits,while starting new instances for each line
the result is a folder full of picture files and it is very tiring to check manually pic by pic if operation succeed knowing that exe don't return a success error code on exit.

i think is more flexible to let exrex do it without any hassle.

by the way the legacy regex linux and windows apps have this feature:
grep -f, --file=FILE load the PATTERN from this FILE
findstr /G:file Gets the strings to search for from the specified file

from exrex.

sebix avatar sebix commented on July 18, 2024

You won't reach your goal without a tiny programming effort.

from exrex.

zdilto avatar zdilto commented on July 18, 2024

i followed your advice and you were right some tiny effort did the job


#add this in  argparser() function
   
  argp.add_argument(
             '-f', '--rexfile',
             help='get regular expression pattern from file',
             metavar='REGEX',
            default=False,
            type=argparse.FileType('r', encoding='utf-8')
    )

#add this in  __main__ function  try block

    if (args['regex'] == "" and args['rexfile'] != ""):
            for line in args['rexfile'].readlines():
                g = generate(line, args['limit'])
    elif(args['regex'] != ""):
            g = generate(args['regex'], args['limit'])
    

from exrex.

rautamiekka avatar rautamiekka commented on July 18, 2024

for /f "tokens=*" %G in ('type patternfile.txt') do (exrex "%~G")|exe params

There's only 1 method to start a single instance: creating a concatenated string from the params. Every single other (that I know of) starts a new instance.

Pretty sure there's a command for screenshots like on Linux, even if you need to install another app. I think it can be done with FFmpeg.

from exrex.

zdilto avatar zdilto commented on July 18, 2024

#add this in  argparser() function
   
  argp.add_argument(
             '-f', '--rexfile',
             help='get regular expression pattern from file',
             metavar='REGEX',
            default=False,
            type=argparse.FileType('r', encoding='utf-8')
    )

#add this in  __main__ function  try block

    if (args['regex'] == "" and args['rexfile'] != ""):
            for line in args['rexfile'].readlines():
                g = generate(line, args['limit'])
    elif(args['regex'] != ""):
            g = generate(args['regex'], args['limit'])
    

after testing and testing again i noticed that only the last line is generated from the patternfile.txt,don't understand why
please help

from exrex.

zdilto avatar zdilto commented on July 18, 2024

work successfully

if (args['regex'] == "" and args['rexfile'] != ""):
        for line in args['rexfile'].readlines():
            try:
                g = generate(line.rstrip(), args['limit'])
            except Exception as e:
                args['rexfile'].close()
                stderr.write('[!] Error: %s\n' % e)
                exit(1)
            args['output'].write(next(g))
            args['max_number'] -= 1
            for s in g:
                if args['max_number'] == 0:
                    break
                args['max_number'] -= 1
                args['output'].write(args['delimiter'])
                args['output'].write(s)
            if args['delimiter'] == '\n':
                args['output'].write('\n')
        args['rexfile'].close()
    elif(args['regex'] != ""):
        try:
            g = generate(args['regex'], args['limit'])
        except Exception as e:
            stderr.write('[!] Error: %s\n' % e)
            exit(1)
        args['output'].write(next(g))
        args['max_number'] -= 1
        for s in g:
            if args['max_number'] == 0:
                break
            args['max_number'] -= 1
            args['output'].write(args['delimiter'])
            args['output'].write(s)
        if args['delimiter'] == '\n':
            args['output'].write('\n')   

exrex -f paternfile.txt ""

from exrex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.