Commit 8713159a authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-restore: improvement

parent 2071a97f
...@@ -26,8 +26,7 @@ load_helper epm-assure ...@@ -26,8 +26,7 @@ load_helper epm-assure
__epm_filter_pip_to_rpm() __epm_filter_pip_to_rpm()
{ {
tr "A-Z" "a-z" | sed -e "s|_|-|g" -e "s|^python[-_]||" \ tr "A-Z" "a-z" | sed -e "s|_|-|g" -e "s|^python[-_]||" \
-e "s|beautifulsoup4|bs4|" \ -e "s|bs4|beautifulsoup4|" \
-e "s|bs4|BeautifulSoup4|" \
-e "s|pillow|Pillow|" \ -e "s|pillow|Pillow|" \
-e "s|sqlalchemy|SQLAlchemy|" \ -e "s|sqlalchemy|SQLAlchemy|" \
-e "s|flask-SQLAlchemy|flask_sqlalchemy|" \ -e "s|flask-SQLAlchemy|flask_sqlalchemy|" \
...@@ -84,7 +83,7 @@ __epm_lineprint_python_array() ...@@ -84,7 +83,7 @@ __epm_lineprint_python_array()
local a="$*" local a="$*"
[ -n "$a" ] || return [ -n "$a" ] || return
local name="$(__epm_get_array_name "$a")" local name="$(__epm_get_array_name "$a")"
(echo "$a" | sed -e 's|\].*|]|' ; echo "print('\n'.join($name))" ) | ( a= python - || a= python3 ) (echo "$a" | sed -E -e 's@(\]|\)).*@\1@' ; echo "print('\n'.join($name))" ) | ( a= python - || a= python3 )
} }
# translate pip requirement lines to rpm notation # translate pip requirement lines to rpm notation
...@@ -94,7 +93,7 @@ __epm_restore_convert_to_rpm_notation() ...@@ -94,7 +93,7 @@ __epm_restore_convert_to_rpm_notation()
local equal="$1" local equal="$1"
local l local l
while read l ; do while read l ; do
if echo "$l" | grep -q "; *python_version *< *'3.0'" ; then if echo "$l" | grep -q "; *python_version *< *['\"]3" ; then
[ -n "$verbose" ] && warning " $t is python2 only requirement, skipped" [ -n "$verbose" ] && warning " $t is python2 only requirement, skipped"
continue continue
fi fi
...@@ -147,7 +146,7 @@ __epm_restore_pip() ...@@ -147,7 +146,7 @@ __epm_restore_pip()
__eresection() __eresection()
{ {
rhas "$1" "[[:space:]]*$2[[:space:]]*=[[:space:]]*\[" rhas "$1" "[[:space:]]*$2[[:space:]]*=[[:space:]]*[\[(]"
} }
__epm_restore_setup_py() __epm_restore_setup_py()
...@@ -188,7 +187,7 @@ $l" ...@@ -188,7 +187,7 @@ $l"
fi fi
# not end of section # not end of section
if [ -z "$section" ] || ! rhas "$l" "\],*" ; then if [ -z "$section" ] || ! rhas "$l" "(\]|\)),*" ; then
continue continue
fi fi
......
#!/bin/sh
load_helper()
{
. ../bin/$1
}
PMTYPE=apt-rpm
. ../bin/epm-sh-altlinux
. ../bin/epm-sh-functions
. ../bin/epm-restore
ok()
{
__eresection "$1" "$2" && echo "$1 OK" || echo "$1 failed"
}
notok()
{
__eresection "$1" "$2" && echo "$1 failed" || echo "$1 OK"
}
ok "install=[" "install"
ok "install=[''" "install"
ok "install=['']" "install"
ok "install=(" "install"
ok "install=(fd" "install"
ok "install=(fd)" "install"
notok "install=fd" "install"
echo
echo "rhas:"
ok()
{
# something is wrong
rhas "$1" "[\])],*" && echo "$1 OK" || echo "$1 failed"
# rhas "$1" "(\]|\)),*" && echo "$1 OK" || echo "$1 failed"
}
ok "),"
ok ")"
ok "]"
ok "],"
ok()
{
# something is wrong
# rhas "$1" "[\])],*" && echo "$1 OK" || echo "$1 failed"
rhas "$1" "(\]|\)),*" && echo "$1 OK" || echo "$1 failed"
}
ok "),"
ok ")"
ok "]"
ok "],"
ok()
{
rhas "$1" "[\[(],*" && echo "$1 OK" || echo "$1 failed"
}
ok "=("
ok "("
ok "=["
ok "[,"
echo
echo "==="
f1()
{
sed -E -e 's@(\]|\)).*@OK@'
}
echo ")," | f1
echo "]" | f1
f1()
{
sed -e 's|[\])].*|OK|'
}
echo ")," | f1
echo "]" | f1
echo
echo "==="
f1()
{
sed -e 's|[\[(].*|OK|'
}
echo "(," | f1
echo "[" | f1
f1()
{
sed -e 's@\(\[|(\).*@OK@'
}
echo "(," | f1
echo "[" | f1
f1()
{
sed -E -e 's@(\[|\().*@OK@'
}
echo "(," | f1
echo "[" | f1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment