Skip to main content

File Sculpt

example workflow example workflow

current version: v0.0.6

This python module abstracts finding and replacing certain portions of a file through regular expressions. It is a class that creates abstraction of the inner workings of opening and closing a file when finding and replacing its contents.

REQUIREMENTS:
  • Python v3.9
  • pip
INSTALLATION:

On your command line inside your project directory type the following:

pip install filesculpt
USAGE:

Importing to your code:

from fileSculpt.filesculpt import Sculptfile
EXAMPLE:

Given a file foo.txt containing the text "A quick brown fox jumps under the lazy dog.", we want the text to become "The quick brown fox jumps over the lazy dog"and save it to another file, foorect.txt.

from fileSculpt.filesculpt import Sculptfile

a = Sculptfile(r'^A(.+)under(.+)',["The",0,"over",1],'foo.txt','foorect.text')
a.sculpt()
CLASS DEFINITION:

This is how the Sculptfile object is defined:

Sculptfile( tofind : re , replacewith : list, inpath : str, outpath : str)
CLASS ARGUMENTS:
  • tofind - is of type re or regular expression which is used to find/define portions of the file to be replaced with

    See https://docs.python.org/3/howto/regex.html for more info on regular expressions

  • replacewith - is a list that should contain either a string or an integer. This list will be rendered in ascending order as replacement for the objects found through regex. An integer refers to the grouping order in a regex query.

    • For example:

      If a file contains 'The quick brown fox' and after regex operations (quick,fox) is obtained, The file's contents can be replaced by assigning a replacewith list formatted as ["A ",0," yellow ",1]. The integers' 0 and 1 represent quick and fox, and when rendered 'A quick yellow fox' is obtained

  • inpath - is a string filepath for the file to be read

  • outpath - is an optional string filepath for the file to be written after operations are done. If not specified the inpath is set as the outpath and changes will overwrite the file.

CLASS METHODS:
  • scuttle() - opens the file specified by inpath as read and returns the regular expression findall() list of the tofind argument

  • sculpt() - executes the scuttle method and then executes the replacement specified by replacewith. Writes the result to the file specified in outpath

Metadata

Release files for filesculpt 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filesculpt 0.0.6
File Size Uploaded
filesculpt-0.0.6.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for filesculpt 0.0.6
File Interpreter ABI Platform
filesculpt-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / filesculpt-0.0.6.tar.gz

Download URL filesculpt-0.0.6.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ddc0bbd10c21bfcb3eca7fc719b5cb24275826ebfa92f4d605b500f01eb76176
BLAKE2b-256 checksum
How to use checksums
c6b8f5d47b859169ff9ffb9602cd211a760d2f39fb396b725e65f13bb759bf0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / filesculpt-0.0.6-py3-none-any.whl

Download URL filesculpt-0.0.6-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b31227c6ce62bfd0e90cbf9108333ed1e795e5ea440e258ca80d468fac7d634e
BLAKE2b-256 checksum
How to use checksums
ece12b1fb0a35e484bfd70ae5d7e0f7703550a0e59dd6dafdfbb9bc27ece31a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page