Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, source, children=False):
self.source = _Source(source)
self.children = children
self.lines = codeanalyze.SourceLinesAdapter(source)
self.children_stack = []
@property
@utils.saveit
def lines(self):
"""A `SourceLinesAdapter`"""
return rope.base.codeanalyze.SourceLinesAdapter(self.source_code)
def _inline_variable(project, pymodule, pyname, name,
remove=True, region=None, docs=False):
definition = _getvardef(pymodule, pyname)
start, end = _assigned_lineno(pymodule, pyname)
occurrence_finder = occurrences.create_finder(project, name, pyname,
docs=docs)
changed_source = rename.rename_in_module(
occurrence_finder, definition, pymodule=pymodule,
replace_primary=True, writes=False, region=region)
if changed_source is None:
changed_source = pymodule.source_code
if remove:
lines = codeanalyze.SourceLinesAdapter(changed_source)
source = changed_source[:lines.get_line_start(start)] + \
changed_source[lines.get_line_end(end) + 1:]
else:
source = changed_source
return source
def __init__(self, source, children=False):
self.source = _Source(source)
self.children = children
self.lines = codeanalyze.SourceLinesAdapter(source)
self.children_stack = []
def lines(self):
"""A `SourceLinesAdapter`"""
return rope.base.codeanalyze.SourceLinesAdapter(self.source_code)
source = _add_imports_to_module(import_tools, pymodule, imports)
pymodule = pycore.get_string_module(source, resource)
source = import_tools.relatives_to_absolutes(pymodule)
pymodule = pycore.get_string_module(source, resource)
source = import_tools.organize_imports(pymodule, selfs=False)
pymodule = pycore.get_string_module(source, resource)
# extracting imports after changes
module_imports = import_tools.module_imports(pymodule)
imports = [import_stmt.import_info
for import_stmt in module_imports.imports]
start = 1
if module_imports.imports:
start = module_imports.imports[-1].end_line
lines = codeanalyze.SourceLinesAdapter(source)
while start < lines.length() and not lines.get_line(start).strip():
start += 1
moving = source[lines.get_line_start(start):]
return moving, imports
source = _add_imports_to_module(import_tools, pymodule, imports)
pymodule = libutils.get_string_module(project, source, resource)
source = import_tools.relatives_to_absolutes(pymodule)
pymodule = libutils.get_string_module(project, source, resource)
source = import_tools.organize_imports(pymodule, selfs=False)
pymodule = libutils.get_string_module(project, source, resource)
# extracting imports after changes
module_imports = import_tools.module_imports(pymodule)
imports = [import_stmt.import_info
for import_stmt in module_imports.imports]
start = 1
if module_imports.imports:
start = module_imports.imports[-1].end_line
lines = codeanalyze.SourceLinesAdapter(source)
while start < lines.length() and not lines.get_line(start).strip():
start += 1
moving = source[lines.get_line_start(start):]
return moving, imports
source = _add_imports_to_module(import_tools, pymodule, imports)
pymodule = libutils.get_string_module(project, source, resource)
source = import_tools.relatives_to_absolutes(pymodule)
pymodule = libutils.get_string_module(project, source, resource)
source = import_tools.organize_imports(pymodule, selfs=False)
pymodule = libutils.get_string_module(project, source, resource)
# extracting imports after changes
module_imports = import_tools.module_imports(pymodule)
imports = [import_stmt.import_info
for import_stmt in module_imports.imports]
start = 1
if module_imports.imports:
start = module_imports.imports[-1].end_line
lines = codeanalyze.SourceLinesAdapter(source)
while start < lines.length() and not lines.get_line(start).strip():
start += 1
# Reinsert the prefix which was removed at the beginning
moving = moving_prefix + source[lines.get_line_start(start):]
return moving, imports
def _inline_variable(project, pymodule, pyname, name,
remove=True, region=None, docs=False):
definition = _getvardef(pymodule, pyname)
start, end = _assigned_lineno(pymodule, pyname)
occurrence_finder = occurrences.create_finder(project, name, pyname,
docs=docs)
changed_source = rename.rename_in_module(
occurrence_finder, definition, pymodule=pymodule,
replace_primary=True, writes=False, region=region)
if changed_source is None:
changed_source = pymodule.source_code
if remove:
lines = codeanalyze.SourceLinesAdapter(changed_source)
source = changed_source[:lines.get_line_start(start)] + \
changed_source[lines.get_line_end(end) + 1:]
else:
source = changed_source
return source