Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to automatically refactor "template" with site name #1

Open
shroffk opened this issue Feb 3, 2016 · 3 comments
Open

Script to automatically refactor "template" with site name #1

shroffk opened this issue Feb 3, 2016 · 3 comments

Comments

@shroffk
Copy link
Member

shroffk commented Feb 3, 2016

it might be nice to have a simple script that quickly replaces all template references with the name of the product

@jeonghanlee
Copy link
Contributor

please explain me "all template references" :)

@shroffk
Copy link
Member Author

shroffk commented Feb 9, 2016

Taking Han's example script and creating

import os
import fileinput

textToSearch="template"
textToReplace="my-product"

'''Fix the features'''
for root, dirs, files in os.walk("features"):
    for file in files:
        if file.endswith(".xml"):
             print(os.path.join(root, file))             
             with fileinput.FileInput(fileToSearch, inplace=True) as file:
                for line in file:
                    print(line.replace(textToSearch, textToReplace))

'''Fix the features'''
for root, dirs, files in os.walk("repository"):
    for file in files:
        if file.endswith(".xml") and "target" not in root:
             print(os.path.join(root, file))
             with fileinput.FileInput(fileToSearch, inplace=True) as file:
                for line in file:
                    print(line.replace(textToSearch, textToReplace))

This script does not handle renaming the necessary files

@jeonghanlee
Copy link
Contributor

Hi Kunal,

After struggling with Python (I could not find a general way to handle them all), I decided to use a simple bash. I don't like this, but it works. Please see the https://github.com/jeonghanlee/org.csstudio.template.product/tree/refactor, which is a branch of my fork repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants