Skip to content

Sourcery refactored master branch - #1

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Aug 5, 2023

Copy link
Copy Markdown

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai
sourcery-ai Bot requested a review from ludoplex August 5, 2023 16:01
Comment on lines -4723 to +4724
write( " static const char " + self.master_table +
"[" + repr( self.total ) + "] =\n" )
write((f" static const char {self.master_table}[{repr(self.total)}" +
"] =\n"))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StringTable.dump refactored with the following changes:

Comment on lines -4737 to +4747
write( "#define " + macro_name + " " + repr( len( sublist ) ) + "\n\n" )
write(f"#define {macro_name} {repr(len(sublist))}" + "\n\n")

write( " /* Values are offsets into the `" +
self.master_table + "' table */\n\n" )
write( " static const short " + table_name +
"[" + macro_name + "] =\n" )
write(f" /* Values are offsets into the `{self.master_table}" +
"' table */\n\n")
write(f" static const short {table_name}[{macro_name}" + "] =\n")
write( " {\n" )

line = " "
comma = ""
col = 0

line = " "

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StringTable.dump_sublist refactored with the following changes:

Comment on lines -4885 to +4887
line = margin + "+-"
if len( self.letter ) == 0:
line += "<NOLETTER>"
else:
line += self.letter

line = f"{margin}+-"
line += "<NOLETTER>" if len( self.letter ) == 0 else self.letter
if self.value:
line += " => " + repr( self.value )
line += f" => {repr(self.value)}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StringNode.dump_debug refactored with the following changes:

Comment on lines -4903 to +4898
if len( self.letter ) > 0:
index += len( self.letter ) + 1
else:
index += 2

index += len( self.letter ) + 1 if len( self.letter ) > 0 else 2

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StringNode.locate refactored with the following changes:

Comment on lines -4991 to +4984
write( " static const unsigned short " + encoding_name +
"[" + repr( len( encoding_list ) ) + "] =\n" )
write((
f" static const unsigned short {encoding_name}[{repr(len(encoding_list))}"
+ "] =\n"))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dump_encoding refactored with the following changes:

Comment on lines -551 to +533
def get_markup( self, tag_name ):
def get_markup( self, tag_name ):
"""return the DocMarkup corresponding to a given tag in a block"""
for m in self.markups:
if m.tag == string.lower( tag_name ):
return m
return None
return next(
(m for m in self.markups if m.tag == string.lower(tag_name)), None
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DocBlock.get_markup refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

Comment on lines -21 to +39
def beautify_block( block ):
if block.content:
content_processor.reset()
def beautify_block( block ):
if not block.content:
return
content_processor.reset()

markups = content_processor.process_content( block.content )
text = []
first = 1
markups = content_processor.process_content( block.content )
text = []
first = 1

for markup in markups:
text.extend( markup.beautify( first ) )
first = 0
for markup in markups:
text.extend( markup.beautify( first ) )
first = 0

# now beautify the documentation "borders" themselves
lines = [" /*************************************************************************"]
for l in text:
lines.append( " *" + l )
lines.append( " */" )
# now beautify the documentation "borders" themselves
lines = [" /*************************************************************************"]
lines.extend(f" *{l}" for l in text)
lines.append( " */" )

block.lines = lines
block.lines = lines

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function beautify_block refactored with the following changes:



def main( argv ):
def main( argv ):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

Comment on lines -41 to +49
def add_identifier( self, name, block ):
def add_identifier( self, name, block ):
if self.identifiers.has_key( name ):
# duplicate name!
sys.stderr.write( \
"WARNING: duplicate definition for '" + name + "' in " + \
block.location() + ", previous definition in " + \
self.identifiers[name].location() + "\n" )
sys.stderr.write(
(
f"WARNING: duplicate definition for '{name}' in {block.location()}, previous definition in {self.identifiers[name].location()}"
+ "\n"
)
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Formatter.add_identifier refactored with the following changes:

Comment on lines -75 to +78
def toc_dump( self, toc_filename = None, index_filename = None ):
output = None
if toc_filename:
output = open_output( toc_filename )

def toc_dump( self, toc_filename = None, index_filename = None ):
output = open_output( toc_filename ) if toc_filename else None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Formatter.toc_dump refactored with the following changes:

output = open_output( index_filename )

def index_dump( self, index_filename = None ):
output = open_output( index_filename ) if index_filename else None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Formatter.index_dump refactored with the following changes:

Comment on lines -157 to +154
def section_dump( self, section, section_filename = None ):
output = None
if section_filename:
output = open_output( section_filename )

def section_dump( self, section, section_filename = None ):
output = open_output( section_filename ) if section_filename else None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Formatter.section_dump refactored with the following changes:

class SourceBlock:

def __init__( self, processor, filename, lineno, lines ):
def __init__( self, processor, filename, lineno, lines ):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SourceBlock.__init__ refactored with the following changes:

def location( self ):
return "(" + self.filename + ":" + repr( self.lineno ) + ")"
def location( self ):
return f"({self.filename}:{repr(self.lineno)})"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SourceBlock.location refactored with the following changes:

Comment on lines -284 to +283
def parse_file( self, filename ):
def parse_file( self, filename ):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SourceProcessor.parse_file refactored with the following changes:

new_list = order_list[:]
for id in input_list:
if not id in order_list:
if id not in order_list:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sort_order_list refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -81 to +87
def check_output():
def check_output():
global output_dir
if output_dir:
if output_dir != "":
if not os.path.isdir( output_dir ):
sys.stderr.write( "argument" + " '" + output_dir + "' " + \
"is not a valid directory" )
sys.exit( 2 )
else:
if output_dir == "":
output_dir = None

elif not os.path.isdir( output_dir ):
sys.stderr.write( "argument" + " '" + output_dir + "' " + \
"is not a valid directory" )
sys.exit( 2 )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_output refactored with the following changes:

Comment on lines -106 to +103
def make_file_list( args = None ):
def make_file_list( args = None ):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function make_file_list refactored with the following changes:

This removes the following comments ( why? ):

# now filter the file list to remove non-existing ones


regs = [ ]
for i in range(0, n):
for _ in range(0, n):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function alloc_regs refactored with the following changes:

l = [ ]
for i in range(0,8):
l.append(matrix[i*4+col])
l = [matrix[i*4+col] for i in range(0,8)]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function shuffle_column refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants