From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 3E7821F44D for ; Wed, 17 Apr 2024 01:12:49 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=h2MgZ7gQ; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwtql-0004OQ-SE; Tue, 16 Apr 2024 21:12:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwtqk-0004OG-GQ for bug-gnulib@gnu.org; Tue, 16 Apr 2024 21:12:34 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwtqi-0002xP-Ir for bug-gnulib@gnu.org; Tue, 16 Apr 2024 21:12:34 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6ed627829e6so5465266b3a.1 for ; Tue, 16 Apr 2024 18:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713316351; x=1713921151; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=fE1n7tudVIlB6NIR9sVjE3PcI5351/jBm2HyRXwXolE=; b=h2MgZ7gQN0R8j1CcZaeYHrbJ7vd7PW+fPJJq0fB2wr7wIjq28WIRpDZML3wznK3tj9 Z0Iq/Hxcswd2vCr2xePBXoYQbNxHTbBujjzw7ZunfZjBEwKM9A8vOML05A6RIIgIPbR8 6OaGj7TlH9n3LYQ4cNNHSjHF5zA7WVN5GGlEaIsx7Xg7LVveHT9twPr+CBjdTAxDPETu MclHC6QqNZReTN3uLqmeiXLHKtt+/7k9P2hHzzjki+m2uxirDXU8LNepHHRY4EWazFvo QXEjNIoYPNfZy9cRPHl2A/Fbftu2Dg7bR48ZGOJc6kRNHaoR5i8jyo3dzamToeVINcRh UWmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713316351; x=1713921151; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fE1n7tudVIlB6NIR9sVjE3PcI5351/jBm2HyRXwXolE=; b=wzoPhElyjZyrzNQsPWUcnUnrqQNPPayihQWaoGf3VpcdV7eMkOVcmiEwjF+CkgiJFp 7UdYx7/HMRakb+6MBLCFdOE7kpPQxv3+huDym3ymUftX5JvroP6/E101BpcQxJ8eJzGM mbdi6WcdwiRSkHC/h1G072OmsiPNGyDF+IbxFxtQBxAtzqGjeLbFlgtztV+xtSEmmmhq Cq/WAt4QD3InSXGL7u5tkBh3C3ZQsSSHLlHHI/SLIvWa6bV3w29zlr4YV8E16crlDNqV AgiMS7TCM2Cs7OpSGsex1erGpp9uIObKLrY35UvrIT6BZOksyMWhYmQtaWmIG+Lety6V ZV8g== X-Forwarded-Encrypted: i=1; AJvYcCVEiUq7bnNQsU5O3N1HYpzqYM47OGOYQ+LuY1HClCrKhgk8KfKXtHriAN07IPaY5JteQgjUAZi7wsduXiu9iTCvDiw= X-Gm-Message-State: AOJu0Yw3gwW6qF0/5zYUNeC0DM63vqUEGapX1Y8/HPC4j1wh25jmtKNL 6ftrxbww/Y9AYky2JGadcPxtQ16IgiEvAnrCYvGC2FsPTQk8vwkL4xxJOw== X-Google-Smtp-Source: AGHT+IHRBbTD8wFdr7bkY5kvkWACxiFSeYU1X0YIUvZIdXl7QAqW6RRqUntswAf529IU7lbBwx5TGQ== X-Received: by 2002:a05:6a00:1312:b0:6ea:dfbf:13d4 with SMTP id j18-20020a056a00131200b006eadfbf13d4mr19049515pfu.18.1713316350906; Tue, 16 Apr 2024 18:12:30 -0700 (PDT) Received: from [192.168.1.5] (c-73-189-213-139.hsd1.ca.comcast.net. [73.189.213.139]) by smtp.gmail.com with ESMTPSA id a13-20020a056a000c8d00b006e7324d32bbsm9605256pfv.122.2024.04.16.18.12.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Apr 2024 18:12:30 -0700 (PDT) Message-ID: <4f567b55-2b44-48a3-9cdb-1a8a9570d589@gmail.com> Date: Tue, 16 Apr 2024 18:12:29 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Refactoring rewrite_filename functions To: Bruno Haible , bug-gnulib@gnu.org References: <6735697.07rScijWmr@nimes> <77cae641-4960-48ea-adf5-6ef28edb658d@gmail.com> <6055935.ntHmXhgcp8@nimes> Content-Language: en-US From: Collin Funk In-Reply-To: <6055935.ntHmXhgcp8@nimes> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=collin.funk1@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Hi Bruno, On 4/16/24 8:09 AM, Bruno Haible wrote: > I'm talking about this piece of code: > > filetable = [] > for src in filelist: > dest = self.rewrite_files([src])[-1] > filetable.append(tuple([dest, src])) > > which can be written as > > filetable = [ tuple([self.rewrite_filename(src), src]) > for src in filelist ] I'm taking a look at this again and I think it would make sense to move these 'rewrite_filename' functions to GLConfig since they only use the directory names stored there. Right now we have the following: 1. GLImport.rewrite_old_files() # Uses self.cache 2. GLImport.rewrite_new_files() # Uses self.config 3. GLTestDir.rewrite_files() # Uses self.config, TestDir has no cache I'm thinking of making this function accept a single filename instead of a list, and then moving it to GLConfig. Omitting the tuple stuff for clarity, but this is how the new/old filename distinction would be handled: # Equals current GLImport.rewrite_old_files() [ self.cache.rewrite_filename(src) for src in filelist ] # Equals current GLImport.rewrite_new_files() [ self.config.rewrite_filename(src) for src in filelist ] What do you think about this change? Also, there is a similar section of code to this new function in main.py line 1313 under "mode == 'copy-file'", but it is missing the 'tests=lib/' replacement. Would there be a way to simplify that too? The use of 'tests=lib/' is escaping my mind at the moment... Collin