File tree Expand file tree Collapse file tree
tests/regrtest_data/duplicate_code/2368 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Database utilities."""
2+
3+
4+ def setup_connection (host , port , database ):
5+ """Set up a database connection with retries."""
6+ retries = 3
7+ timeout = 30
8+ connection_string = f"{ host } :{ port } /{ database } "
9+ print (f"Connecting to { connection_string } " )
10+ for attempt in range (retries ):
11+ print (f"Attempt { attempt + 1 } of { retries } " )
12+ if attempt > 0 :
13+ print (f"Waiting { timeout } seconds before retry" )
14+ return connection_string
Original file line number Diff line number Diff line change 1+ """Project utilities."""
2+
3+
4+ def setup_connection (host , port , database ):
5+ """Set up a database connection with retries."""
6+ retries = 3
7+ timeout = 30
8+ connection_string = f"{ host } :{ port } /{ database } "
9+ print (f"Connecting to { connection_string } " )
10+ for attempt in range (retries ):
11+ print (f"Attempt { attempt + 1 } of { retries } " )
12+ if attempt > 0 :
13+ print (f"Waiting { timeout } seconds before retry" )
14+ return connection_string
Original file line number Diff line number Diff line change 1+ """XML generation — no duplicate code here."""
2+ import xml .etree .ElementTree as ET
3+
4+
5+ def generate_xml (data ):
6+ """Generate an XML document from data."""
7+ root = ET .Element ("root" )
8+ for key , value in data .items ():
9+ child = ET .SubElement (root , key )
10+ child .text = str (value )
11+ return ET .tostring (root , encoding = "unicode" )
You can’t perform that action at this time.
0 commit comments