This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
forked from akretion/nfselib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate
executable file
·75 lines (60 loc) · 2.06 KB
/
generate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# the project file layout is a template clone of http://www.davekuhlman.org/generateDS.html#id14
# for which we run:
git branch -D generated
git checkout -b generated
SCHEMA_NAME='nfse'
python quick_start.py --schema-name="$SCHEMA_NAME"
export GENERATEDS_HOME=${GENERATEDS_HOME:="/home/rvalyi/DEV/generateds"}
generate() {
local version=$1
local schemas_url=$2
local lib_name="$SCHEMA_NAME"lib
local gen_path="$SCHEMA_NAME"lib/"$version"
wget -qO- --no-check-certificate "$schemas_url" -O /tmp/schemas.zip
rm -rf "schemas/$version"
unzip /tmp/schemas.zip -d schemas/"$version"
rm /tmp/schemas.zip
mv schemas/"$version"/nfse*.txt schemas/"$version"/nfse.xsd
sed -i 's/ xsd:/<xsd:/' schemas/"$version"/nfse.xsd # FIXES schema typo
rm -rf __init__.py
local module_contents=$(cat <<EOF
Module contents
=================
EOF
)
echo "$module_contents" > docs/module_contents.txt
echo "sys.path.append(os.path.abspath('../$gen_path'))" >> docs/conf.py
rm -rf $gen_path
mkdir -p $gen_path
touch "$lib_name"/__init__.py
touch "$gen_path/__init__.py"
for f in "schemas/$version"/*.xsd;
do
echo "Processing $f file..";
local name=$(echo "$f" | sed 's/\.xsd//g' | sed 's/\./_/g' | sed "s/_$version//g")
local module_name=$(echo $name | tr "/" "\n" | tail -n1)
# generateDS -o "$gen_path/$module_name".py -s "$gen_path/$module_name"_subs.py "$f"
python3 "$GENERATEDS_HOME"/generateDS.py -o "$gen_path/$module_name".py "$f"
autopep8 --in-place -p3 "$gen_path/$module_name".py
module_name=$(echo $name | tr "/" "\n" | tail -n1)
module_contents_part=$(cat <<EOF
.. automodule:: $module_name
:members:
:undoc-members:
:show-inheritance:
EOF
)
echo "$module_contents_part" >> docs/module_contents.txt
done
}
generate "v2_03" "http://www.abrasf.org.br/arquivos/publico/NFS-e/Versao_2.03/schema_xml_nfs-e_%20v2.03.zip"
cd docs
make html
cd ..
rm -rf README.txt
rm -rf "$SCHEMA_NAME"utils.py
rm -rf sample_code
git add .
git commit . -m "classes and doc generated with ./generate"
git merge packaging