Create URL data with %20 substituted for spaces.
Usage
The ConvertSpaces Python script is used to create URL data with %20 substituted for spaces in the name entered.
If an option specifying the STRS web form type (PM, RM, LL, UH, or RQ), the URL location is inserted.
If the -SUB option is specified, the number is expanded to 6 digits by adding zeroes on the left and adding it as the submittal number.
The name may be entered on the command line or, if omitted, it will be prompted for.
Multiple spaces are condensed.
The STRS web form types are:
- PM = Public Metadata for Submittal Form
- RM = Restricted Metadata for Submittal Form
- LL = Lesson Learned Form
- UH = User History/Survey Form
- RQ = Application Request Form
Setup
- Install Python. See Python download site. The script was tested against Python 2.7 and Python 3.2. Since there were residual errors when handling special characters in Python 2.7, it is recommended that the user install and use Python 3.2 or above.
- Create/find a working directory to store scripts.
- Save the ConvertSpaces.python.txt script into that working directory.
Execution
- Display the email or other message showing the name of the submitted or requested STRS application, OE, component, or tool.
- In a command window, execute the python script ConvertSpaces.python.txt as shown, copying and pasting the STRS application name at the end of the command line or on the line following the prompt.
usage: python ConvertSpaces.python.txt [-h| --help] [-PM|-RM|-LL|-UH|-RQ] [Text to convert] Convert text to %20 delimited URL. positional arguments: dataIn Text to convert. optional arguments: -h, --help show this help message and exit -PM Public Metadata URL. -RM Restricted Metadata URL. -LL Lessons Learned URL. -UH Usage History / Survey URL. -RQ Request Form URL. -SUB ssssss STRS Repository Submittal Number.
- In a PC command window, I used python to execute the script.
In other platforms’ command window, python27 or python3 was executed.
It may have needed a directory path prepended if the installation did not update the PATH variable.
When the script is executed, it will prompt for any missing application name string to convert.- In a PC command window, the following was executed with no options:
>python ConvertSpaces.python.txt This is my name
Now = Oct 23, 2017, 14:06 = 20171023140645
Skip -SUB:(nothing)
*********************
This%20is%20my%20name
*********************
- In a PC command window, the following was executed with LL option:
>python ConvertSpaces.python.txt -LL This is my name
Now = Oct 23, 2017, 14:07 = 20171023140704
Skip -SUB:(nothing)
***************************************************************** *********************
https://strs.grc.nasa.gov/repository/forms/lessons-learned/?Name= This%20is%20my%20name
***************************************************************** *********************
- In a PC command window, the following was executed with LL and SUB option:
>python ConvertSpaces.python.txt -LL -SUB 2 This is my name
Now = Oct 23, 2017, 14:07 = 20171023140721
***************************************************************** *****************************************************
https://strs.grc.nasa.gov/repository/forms/lessons-learned/?Name= This%20is%20my%20name;SubmittalNumber=STRS-SUB-000002
***************************************************************** *****************************************************
- In a PC command window, the following was executed with LL and SUB options but no data on the command line:
>python ConvertSpaces.python.txt -LL -SUB 2
Now = Oct 23, 2017, 14:08 = 20171023140855
Enter string to convert: This is my name
***************************************************************** *****************************************************
https://strs.grc.nasa.gov/repository/forms/lessons-learned/?Name= This%20is%20my%20name;SubmittalNumber=STRS-SUB-000002
***************************************************************** *****************************************************
- In a PC command window, the following was executed with no options:
- Copy and paste the result (between asterisks) into the new email.