Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

reprec: Recursively replace strings in files and other goodies

Project Description

reprec: Recursively replace strings in files and other goodies

Command line tool for text files.

https://github.com/guettli/reprec

Tools

Up to now there are these tools:

  • reprec: Replace strings in text files. Can work recursive in a directory tree
  • setops: Set operations (union, intersection, …) for line based files.

reprec

The tool reprec replaces strings in text files:

===> reprec --help
Usage: reprec
         [-p|--pattern] p
         [-i|--insert] i
         [-f|--filename regex]
         [-n|--no-regex]
         [-v|--verbose]
         [-a|--ask]
         [--print-lines]
         [--dotall]
         [--ignorecase]
         [--novcexclude]
         [--files-from file|-]
         [--ignore regex]

         dirs

    dirs:        Directories or files for replacing. Use is '.' for current dir.

    pattern:     Regex pattern.

    insert:      Text which gets inserted

    filename:    Regex matching the filename. E.g. '.*\.py'

    no-regex:    Normal string replacement will be used.
                 This means you can use '.', '*', '[' without quoting

    verbose:     Print the number of changes for each file

    print-lines: Print the old and the new line for each change.
                 Not available if --dotall is used.

    dotall:      In regular expressions '.' matches newlines, too.
                 Not supported with --ask and --print-lines.

    ignorecase:  ...

    novcexclude: Don't exclude the directories called '.svn' or 'CVS'.
                 By default they get ignored.

    ask:         Aks before replacing (interactive).

    files-from:  Read filenames from file or stdin if '-'.
                 Skip directories.

    ignore:      Ignore lines that match a regular expression.
                 This options can be given several times.

    Example:
     reprec --pattern '(xml)' --insert '\1\1' .
     -->This will replace all 'xml' with 'xmlxml'

     Or, shorter:
     reprec '(xml)' '\1\1'

    Example2:
     find -mtime -1 -name '*.py' | reprec --files-from=- foo bar


    The Perl Compatible Regular Expresssions are explained here:
      http://docs.python.org/lib/re-syntax.html

    The files are created by moving (os.rename()) FILE_RANDOMINTEGER
    to FILE. This way no half written files will be left, if the
    process gets killed. If the process gets killed one FILE_RANDOMINTEGER
    may be left in the filesystem.

setops

The tool setops provides set operations (union, intersection, …) for line based files:

usage: setops [-h] set1 operator set2

Operators:
  union Aliases: | + or
  intersection Aliases: & and
  difference Aliases: - minus
  symmetric_difference Aliases: ^

Example: Show all files in directory "a" which are not in directory "b":
setops <(cd a; find ) - <(cd b; find )

positional arguments:
  set1
  operator
  set2

optional arguments:
  -h, --help  show this help message and exit
Release History

Release History

This version
History Node

2017.24.0

History Node

2017.23.0

History Node

2017.22.0

History Node

2017.21.0

History Node

2017.20.0

History Node

2017.19.0

History Node

2017.18.0

History Node

2017.17.0

History Node

2017.16.0

History Node

2017.15.0

History Node

2017.14.0

History Node

2016.5

History Node

2016.3

History Node

2016.2

History Node

2016.1

History Node

2015.7

History Node

2015.6

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
reprec-2017.24.0.tar.gz (8.1 kB) Copy SHA256 Checksum SHA256 Source Nov 6, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting