nebius/SWE-bench-extra huggingface dataset:
Repository: d-Rickyy-b/pyBrematic

Issue:
ITGW-433 requires a slightly updated head and tail formatter
The head and tail formatter for the Intertechno gateway were missing a trailing "0". After adding these, the ITGW-433 can operate a CMR1000.

The corresponding work can be found here:
https://www.instructables.com/Intertechno-LAN-Gateway-ITGW-433-and-OpenHAB/

Comments:

Patch:
diff --git a/pyBrematic/gateways/intertechno_gateway.py b/pyBrematic/gateways/intertechno_gateway.py
index b10a935..c6d4c4d 100644
--- a/pyBrematic/gateways/intertechno_gateway.py
+++ b/pyBrematic/gateways/intertechno_gateway.py
@@ -14,8 +14,8 @@ class IntertechnoGateway(Gateway):
         # For the Intertechno GWY 433 the parameters look like that:
         # head: "0,0,<repeat>,<pause>,<tune>,<baud>"
         # tail: "<txversion>,<speed>"
-        self.head_format = "0,0,{0},{1},{2},{3}"
-        self.tail_format = "{0},{1}"
+        self.head_format = "0,0,{0},{1},{2},{3},0"
+        self.tail_format = "{0},{1},0"
 
     def build_udp_payload(self, device, action):
         head = self.get_head(device.repeat, device.pause_IT, device.tune, device.baud_IT)


Test patch:
diff --git a/pyBrematic/gateways/tests/intertechno_gateway_test.py b/pyBrematic/gateways/tests/intertechno_gateway_test.py
index 69f798d..1b1c19e 100644
--- a/pyBrematic/gateways/tests/intertechno_gateway_test.py
+++ b/pyBrematic/gateways/tests/intertechno_gateway_test.py
@@ -36,7 +36,7 @@ class TestIntertechnoGateway(unittest.TestCase):
         device.get_signal = get_signal_mock
 
         payload = self.gw.build_udp_payload(device, Action.ON)
-        self.assertEqual("0,0,2345,111,557,91919,A,SIGNAL-A,B,B,A-SIGNAL,C,1,432", payload)
+        self.assertEqual("0,0,2345,111,557,91919,0,A,SIGNAL-A,B,B,A-SIGNAL,C,1,432,0", payload)
         get_signal_mock.assert_called_once_with(Action.ON)
 
     def test_get_head(self):
Repository: d3dave/cough

Issue:
Exception when adding an uninitialized section before an initialized section
file.py:133 is inconsistent with file.py:144

Comments:

Patch:
diff --git a/cough/file.py b/cough/file.py
index 84338e7..d96aa8a 100644
--- a/cough/file.py
+++ b/cough/file.py
@@ -125,25 +125,17 @@ class ObjectModule:
         return bytes(body_buffer)
 
     def dump_sections(self):
+        data_buf_offset = FileHeader.struct.size + 40 * len(self.sections)
+        hdrs_buf = bytearray()
         data_buf = bytearray()
-        sections_offsets = []
-        reloc_offsets = []
         for sec in self.sections:
             if sec.data:
-                sections_offsets.append(len(data_buf))
+                sec.pointer_to_raw_data = data_buf_offset + len(data_buf)
                 data_buf += sec.data
             if sec.relocations:
-                reloc_offsets.append(len(data_buf))
+                sec.pointer_to_relocations = data_buf_offset + len(data_buf)
                 for reloc in sec.relocations:
                     data_buf += reloc.pack()
+            hdrs_buf += sec.get_header()
 
-        sections_buffer_offset = FileHeader.struct.size + 40 * len(self.sections)
-        hdrs_and_data_buf = bytearray()
-        for i, sec in enumerate(self.sections):
-            if sec.data:
-                sec.pointer_to_raw_data = sections_buffer_offset + sections_offsets[i]
-            if sec.relocations:
-                sec.pointer_to_relocations = sections_buffer_offset + reloc_offsets[i]
-            hdrs_and_data_buf += sec.get_header()
-        hdrs_and_data_buf += data_buf
-        return bytes(hdrs_and_data_buf)
+        return bytes(hdrs_buf + data_buf)


Test patch:
diff --git a/tests/test_coff.py b/tests/test_coff.py
index 8ca9ce4..2193214 100644
--- a/tests/test_coff.py
+++ b/tests/test_coff.py
@@ -63,3 +63,16 @@ def test_reloc():
     subprocess.run(['PowerShell.exe', BUILD_SCRIPT, file.name, '/out:' + '"' + exe_path + '"'], check=True)
     proc = subprocess.run([exe_path], stdout=subprocess.PIPE, check=True)
     assert proc.stdout == b'A'
+
+
+def test_uninit_before_init():
+    module = cough.ObjectModule()
+
+    sec_uninit = cough.Section(b'uninit', cough.SectionFlags.CNT_UNINITIALIZED_DATA)
+    sec_uninit.size_of_raw_data = 0x400
+    module.sections.append(sec_uninit)
+
+    sec_init = cough.Section(b'init', 0, b'\xAA\xBB\xCC\xDD')
+    module.sections.append(sec_init)
+
+    assert module.get_buffer()
Repository: dag-hammarskjold-library/dlx

Issue:
Allow building only certain fields in build-logical-fields script
Add an option to limit the build action to specific fields. This will be useful when an individual field configuration is updated, and only that field(s) needs to be rebuilt.

Comments:

Patch:
diff --git a/dlx/scripts/build_logical_fields.py b/dlx/scripts/build_logical_fields.py
index 769dd74..55948a2 100644
--- a/dlx/scripts/build_logical_fields.py
+++ b/dlx/scripts/build_logical_fields.py
@@ -16,10 +16,11 @@ parser.add_argument('--connect', required=True, help='MongoDB connection string'
 parser.add_argument('--database', help='The database to use, if it differs from the one in the connection string')
 parser.add_argument('--type', required=True, choices=['bib', 'auth'])
 parser.add_argument('--start', default=0)
+parser.add_argument('--fields', help='Only build these fields', nargs='+')
   
 def run():
     args = parser.parse_args()
-    DB.connect(args.connect, database=args.database)
+    #DB.connect(args.connect, database=args.database)
 
     build_logical_fields(args)
     #build_auth_controlled_logical_fields(args) # disabled
@@ -27,6 +28,8 @@ def run():
     if args.type == 'auth':
         calculate_auth_use()
 
+    return True
+
 def build_logical_fields(args):
     cls = BibSet if args.type == 'bib' else AuthSet
     auth_controlled = Config.bib_authority_controlled if cls == BibSet else Config.auth_authority_controlled
@@ -38,6 +41,9 @@ def build_logical_fields(args):
         #    tags += list(d.keys())
         #    names.append(field)
 
+        if args.fields and field not in args.fields:
+            continue
+
         tags += list(d.keys()) + (Config.bib_type_map_tags() if cls == BibSet else Config.auth_type_map_tags())
         names.append(field)
 


Test patch:
diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index eea6fb6..4fc8b05 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -38,9 +38,18 @@ def test_build_logical_fields(db):
         .set('246', 'a', 'Alt title') \
         .set('650', 'a', 1) \
         .commit()
-    
-    # interim
-    assert build_logical_fields.run() is None
+
+    # delete the logical field that was created on commit to test that the script adds it
+    bib.handle().update_one({'_id': bib.id}, {'$unset': {'title': 1}})
+    assert bib.handle().find_one({'_id': bib.id}).get('title') is None
+    assert build_logical_fields.run() == True
+    assert bib.handle().find_one({'_id': bib.id}).get('title') == ['Title: subtitle', 'Alt title']
+
+    # test fields arg
+    bib.handle().update_one({'_id': bib.id}, {'$unset': {'title': 1}})
+    sys.argv[1:] = ['--connect=mongomock://localhost', '--type=bib', '--fields=dummy1 dummy2']
+    assert build_logical_fields.run() == True
+    assert bib.handle().find_one({'_id': bib.id}).get('title') is None
 
 def test_build_text_collections(db):
     from dlx.marc import Bib