MCPcopy
hub / github.com/rocky/python-uncompyle6 / main_bin

Function main_bin

uncompyle6/bin/uncompile.py:142–320  ·  view source on GitHub ↗

Cross Python bytecode decompiler for Python bytecode up to Python 3.8.

(
    asm: bool,
    asm_plus: bool,
    show_grammar,
    tree: bool,
    tree_plus: bool,
    linemaps: bool,
    verify,
    recurse_dirs: bool,
    outfile,
    start_offset: int,
    stop_offset: int,
    files,
)

Source from the content-addressed store, hash-verified

140)
141@click.argument("files", nargs=-1, type=click.Path(readable=True), required=True)
142def main_bin(
143 asm: bool,
144 asm_plus: bool,
145 show_grammar,
146 tree: bool,
147 tree_plus: bool,
148 linemaps: bool,
149 verify,
150 recurse_dirs: bool,
151 outfile,
152 start_offset: int,
153 stop_offset: int,
154 files,
155):
156 """
157 Cross Python bytecode decompiler for Python bytecode up to Python 3.8.
158 """
159
160 version_tuple = sys.version_info[0:2]
161 if version_tuple < (3, 6):
162 print(
163 f"Error: This version of the {program} runs from Python 3.6 or greater."
164 f"You need another branch of this code for Python before 3.6."
165 f""" \n\tYou have version: {version_tuple_to_str()}."""
166 )
167 sys.exit(-1)
168
169 numproc = 0
170 out_base = None
171
172 out_base = None
173 source_paths: List[str] = []
174 timestamp = False
175 timestampfmt = "# %Y.%m.%d %H:%M:%S %Z"
176 pyc_paths = files
177
178 # Expand directory if "recurse" was specified.
179 if recurse_dirs:
180 expanded_files = []
181 for f in pyc_paths:
182 if os.path.isdir(f):
183 for root, _, dir_files in os.walk(f):
184 for df in dir_files:
185 if df.endswith(".pyc") or df.endswith(".pyo"):
186 expanded_files.append(os.path.join(root, df))
187 pyc_paths = expanded_files
188
189 # argl, commonprefix works on strings, not on path parts,
190 # thus we must handle the case with files in 'some/classes'
191 # and 'some/cmds'
192 src_base = os.path.commonprefix(pyc_paths)
193 if src_base[-1:] != os.sep:
194 src_base = os.path.dirname(src_base)
195 if src_base:
196 sb_len = len(os.path.join(src_base, ""))
197 pyc_paths = [f[sb_len:] for f in pyc_paths]
198
199 if not pyc_paths and not source_paths:

Callers 1

uncompile.pyFile · 0.85

Calls 7

mainFunction · 0.90
status_msgFunction · 0.90
usageFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45
putMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected