-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathmodule_printer.py
More file actions
31 lines (25 loc) · 1014 Bytes
/
module_printer.py
File metadata and controls
31 lines (25 loc) · 1014 Bytes
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
import sys
from semmle import util
from .py_extractor import PythonExtractor
class ModulePrinter(object):
name = "module printer"
def __init__(self, options, trap_folder, src_archive, renamer, logger):
self.logger = logger
self.py_extractor = PythonExtractor(options, trap_folder, src_archive, logger)
def process(self, unit):
imports = ()
if isinstance(unit, util.BuiltinModuleExtractable):
name = unit.name
self.logger.info("Found builtin module '%s'", name)
elif isinstance(unit, util.FileExtractable):
self.logger.info("Found file '%s'", unit.path)
_, imports = self.py_extractor._get_module_and_imports(unit)
elif isinstance(unit, util.FolderExtractable):
self.logger.info("Found folder '%s'", unit.path)
else:
self.logger.error("Unexpected object: %s", unit)
return imports
def close(self):
pass
def write_global_data(self):
pass