-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit c0714f4.
- Loading branch information
Showing
1 changed file
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
# import re | ||
# import sys | ||
# import os | ||
# | ||
# APP_CONFIG_FILE = sys.argv[1] | ||
# APP_KEY = sys.argv[2] | ||
# BASE_URL = sys.argv[3] | ||
# | ||
# | ||
# # Stub a string with a evironment variable | ||
# def stubString(searchPattern, rejectPattern, searchtText, replacement, desc): | ||
# searchRet = re.search(searchPattern, searchtText).group() | ||
# if re.search("\"{}\"".format(rejectPattern), searchRet) is not None: | ||
# "A valid {} is submitted!".format(desc) | ||
# sys.exit(1) | ||
# | ||
# # Stub valid key and write back | ||
# ret = re.sub('\"\S+\"', "\"{}\"".format(replacement), searchRet) | ||
# ret = re.sub(searchPattern, ret, searchtText) | ||
# return ret | ||
# | ||
# | ||
# # Read heaer file | ||
# | ||
# io = open(APP_CONFIG_FILE, "r+") | ||
# text = io.read() | ||
# | ||
# ret = stubString("std::string\sappKey\s?=\s?\"\S*\";", "^[a-f0-9]{32}$", text, APP_KEY, 'APP_KEY') | ||
# ret = stubString("std::string\sbaseURL\s?=\s?\"\S*\";", | ||
# "(?:rtmp:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+", ret, | ||
# BASE_URL, 'BASE_URL') | ||
# | ||
# io.seek(0) | ||
# io.write(ret) | ||
# io.truncate() | ||
# | ||
# io.close() | ||
import re | ||
import sys | ||
import os | ||
|
||
APP_CONFIG_FILE = sys.argv[1] | ||
APP_KEY = sys.argv[2] | ||
BASE_URL = sys.argv[3] | ||
|
||
|
||
# Stub a string with a evironment variable | ||
def stubString(searchPattern, rejectPattern, searchtText, replacement, desc): | ||
searchRet = re.search(searchPattern, searchtText).group() | ||
if re.search("\"{}\"".format(rejectPattern), searchRet) is not None: | ||
"A valid {} is submitted!".format(desc) | ||
sys.exit(1) | ||
|
||
# Stub valid key and write back | ||
ret = re.sub('\"\S+\"', "\"{}\"".format(replacement), searchRet) | ||
ret = re.sub(searchPattern, ret, searchtText) | ||
return ret | ||
|
||
|
||
# Read heaer file | ||
|
||
io = open(APP_CONFIG_FILE, "r+") | ||
text = io.read() | ||
|
||
ret = stubString("std::string\sappKey\s?=\s?\"\S*\";", "^[a-f0-9]{32}$", text, APP_KEY, 'APP_KEY') | ||
ret = stubString("std::string\sbaseURL\s?=\s?\"\S*\";", | ||
"(?:rtmp:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+", ret, | ||
BASE_URL, 'BASE_URL') | ||
|
||
io.seek(0) | ||
io.write(ret) | ||
io.truncate() | ||
|
||
io.close() |