Content
pyarmor init
Create Project
Append Project Item
pyarmor env
Show Project Information
Update Project
pyarmor build
List Project Scripts
Build RFT Script
Refactor complex script by autofix mode
Build Mini Script
digraph G { node [shape=box, style=rounded, target="_top"] opts [shape=record label="{-C|-s|-r|-x}"] init [label="pyarmor init"] conf [label="Config file: .pyarmor/config"] init -> opts [label="By options" dir=back arrowtail=curve] rank=same { init -> conf [label="Save to"] } }
Create Project¶
digraph G { node [shape=box, style=rounded, target="_top"] opts [shape=record label="{-e|-m|-p}"] init [label="pyarmor init"] conf [label="Config file: .pyarmor/config"] init -> opts [label="By options" dir=back arrowtail=curve] rank=same { init -> conf [label="Save to"] } }
Append Project Item¶
digraph G { node [shape=box, style=rounded, target="_top"] init [label="pyarmor env -p info"] conf [label="Config file: .pyarmor/config"] info [label="Project Information"] rank=same { conf -> init [label="Read" arrowhead=curve] } init -> info [label="Print"] }
Show Project Information¶
digraph G { node [shape=box, style=rounded, target="_top"] opts [label="Project Options" href="../../docs/en/configuration.html"] env [label="pyarmor env -p set opt value"] conf [label="Config file: .pyarmor/config"] env -> opts [dir=back arrowtail=curve] rank=same { env -> conf [label="Write"] } }
Update Project¶
digraph G { node [shape=box, style=rounded, target="_top"] conf [label="Config file: .pyarmor/config" href="../../docs/en/configuration.html"] build [label="pyarmor build --list"] items [label="Print all script name in project"] conf -> build [label="Read" arrowhead=curve] build -> items [label="Search files by project"] }
List Project Scripts¶
digraph G { node [shape=box, style=rounded, target="_top"] build [label="pyarmor build --rft" style="filled,rounded" fillcolor="wheat"] join1 [shape=point] items [label="Process each script"] conf [label="Project file: .pyarmor/config 中"] rules [shape=plaintext label="Got RFT options from:\n.pyarmor/config"] autofix [shape=plain label="Got autofix rules from:\n.pyarmor/project/rft_autofix.rules"] p1 [label="Apply refactor rulers"] rft [label="Generate RFT Script"] build -> join1 join1 -> conf [dir=none] join1 -> items [label="Get all scripts in project"] items -> p1 rank=same { p1 -> rft } p1 -> rules [arrowtail=curve dir=back] p1 -> autofix [arrowtail=curve dir=back] }
Build RFT Script¶
There are 3 autofix mode
Mode 1: simple way, but many attributes may not be renamed
Mode 2: normal way, most attributes will be renamed, but sometimes need manually update the rules
Mode 3: difficult way, it could rename attributes as many as possible (more than mode 2), need manually add most of rules
digraph G { node [shape=box, style=rounded, target="_top"] build [label="pyarmor build --autofix 1" style="filled,rounded" fillcolor="wheat"] join1 [shape=point] items [label="Process each script"] conf [label="Project file: \n.pyarmor/config"] rules [shape=plaintext label="Got RFT options from:\n.pyarmor/config"] autofix [shape=component style="filled" fillcolor="tan" label="Generate autofix rules to\n.pyarmor/project/rft_autofix.rules\nDo not rename all unknown attributes"] p1 [label="Apply refactor rules"] rft [label="Try to refactor script\nIf not sure to rename one attribute\nRecord it to unknown attribute list"] loop [label="Merge all unknown attribute list"] build -> join1 join1 -> conf [dir=none] join1 -> items [label="Get all scripts in project"] items -> p1 rank=same { p1 -> rft } p1 -> rules [arrowtail=curve dir=back] rft -> loop -> autofix rebuild [style="filled,rounded" fillcolor="wheat" label="Rebuild project\npyarmor build --rft"] test [label="Run RFT script\npython dist/foo.py"] fb [label="Does it raise AttributeError?"] f2 [label="Exclude this attribute:\npyarmor env -p push rft:exclude_names xxxx"] autofix -> rebuild -> test -> fb fb -> f2 [label="AttributeError is raised"] f2 -> rebuild [label="Loop until there is no error" headport=e tailport=e] }
Refactor Complex Script Autofix Mode 1¶
digraph G { node [shape=box, style=rounded, target="_top"] build [label="pyarmor build --autofix 2" style="filled,rounded" fillcolor="wheat"] join1 [shape=point] items [label="Process each script"] conf [label="Project file: \n.pyarmor/config"] rules [shape=plaintext label="Got RFT options from:\n.pyarmor/config"] p1 [label="Apply refactor rules"] rft [label="Try to refactor scripts\nIf not sure to rename one attribute\nRecord it to Unknown Attribute Table"] u1 [label="Read all builtin types and\nExternal types defined in the RFT options"] un [label="Merge all attributes of \nboth external types and builtin types\nGet External Attribute Table"] u1 -> un autofix [shape=component style="filled" fillcolor="tan" label="Generate autofix rules to\n.pyarmor/project/rft_autofix.rules\nDo not rename intersection of \nUnknown Attributes and External Attributes\nRename all the other unknown attributes"] un -> autofix build -> join1 join1 -> conf [dir=none] join1 -> items [label="Get all scripts in project"] items -> p1 rank=same { p1 -> rft [dir=normal] } p1 -> rules [arrowtail=curve dir=back] rft -> autofix rebuild [style="filled,rounded" fillcolor="wheat" label="Rebuild project:\npyarmor build --rft"] test [label="Run RFT script:\npython dist/foo.py"] fb [label="Does it raise AttributeError?"] f1 [label="If this attribute has been renamed\nSearch it in .pyarmor/project/rft_autofix.rules\nGet the original attribute"] f2 [label="Exclude the original attribute:\npyarmor env -p push rft:exclude_names xxxx"] f3 [label="Advanced way"] f4 [label="Check autofix log by Emacs org-mode:\n.pyarmor/rft_autofix.2.org"] f5 [label="Look through each attribute in the log\nIf this attribute shouldn't be rename\nAppend it to RFT options:\npyarmor env -p push external_attrs XXXX"] f6 [label="Restart\npyarmor build --autofix 2" style="filled,rounded" fillcolor="wheat"] autofix -> rebuild -> test -> fb fb -> f1 [label="AttributeError is raised"] f1 -> f2 [label="Simple way"] f2 -> rebuild [label="Loop until there is no error" tailport=e] f1 -> f3 -> f4 -> f5 -> f6 }
Refactor Complex Script Autofix Mode 2¶
digraph G { node [shape=box, style=rounded, target="_top"] build [label="pyarmor build --autofix 3" style="filled,rounded" fillcolor="wheat"] join1 [shape=point] items [label="Process each script"] conf [label="Project file: \n.pyarmor/config"] rules [shape=plaintext label="Got RFT options from:\n.pyarmor/config"] p1 [label="Apply refactor rules"] rft [label="Try to refactor scripts"] n1 [label="Iter each type defined in the project\nGenerate Internal Attribute Table"] n2 [label="If not sure to rename one attribute\nRecord it to Unknown Attribute Table"] autofix [shape=component style="filled" fillcolor="tan" label="Generate autofix rules to\n.pyarmor/project/rft_autofix.rules\nRename all names in Internal Attribute Table"] autolog [shape=box style="filled,rounded" fillcolor="tan" label="Generate autofix log:\n.pyarmor/project/rft_autofix.3.org"] build -> join1 join1 -> conf [dir=none] join1 -> items [label="Get scripts in the project"] items -> p1 rank=same { p1 -> rft } p1 -> rules [arrowtail=curve dir=back] rft -> n1 -> autofix rft -> n2 [tailport=e] n2 -> autolog m1 [label="Create RFT rules manually"] autolog -> m1 [label="Look through autofix log"] m1 -> autofix [label="Append rules"] rebuild [style="filled,rounded" fillcolor="wheat" label="Rebuild project:\npyarmor build --rft"] test [label="Run RFT script:\npython dist/foo.py"] fb [label="Does it raise AttributeError?"] autofix -> rebuild -> test -> fb fb -> m1 [label="AttributeError is raised"] }
Refactor Complex Script Autofix Mode 3¶
digraph G { node [shape=box, style=rounded, target="_top"] build [label="pyarmor build --mini" style="filled,rounded" fillcolor="wheat"] join1 [shape=point] items [label="Process each script"] conf [label="Project file: .pyarmor/config"] mini [label="Generate Mini Script"] build -> join1 join1 -> conf [dir=none] join1 -> items [label="Get all scripts in the project"] items -> mini }
Build Mini Script¶
Project
How to