StryPy in a program

StryPy can also be used as part of a larger program in a Python file. In this small project we will implement it in a file path splitter and editor for Linux and Mac.

First import the neccessary packages:

1import strypy as sp

Then create the function to split a file path to get a list of directorys:

2def split_path(path):
3    return sp.split(path,'/')

And the function to go back a directory:

 4def back(path, copy=False):
 5    split = split_path(path)
 6    new_split = split.pop()
 7    new_path = sp.join(new_split, between='/')
 8
 9    if copy == True:
10        sp.copy(new_path)
11
12    return new_path

Add a new directory on the end:

13def add_path(path, add, copy=False):
14    new_path = sp.add(path, "/", str(add))
15
16    if copy == True:
17        sp.copy(new_path)
18
19    return new_path